nodejs/next/inject-into-static Created 2024-08-27 Updated 2025-07-16
In this example we attempt to inject React elements into statically rendered HTML coming from the server, and properly hydrate them.
Questions by Ciro Santilli:
nodejs/next/ref-twice Created 2024-08-27 Updated 2025-07-16
This is a minimal reproducible example for the terrible problem of external effects applying twice to refs for effects that are not idempotent and thus blowup if applied twice.
The issue is currently discussed at: react.dev/learn/synchronizing-with-effects#step-3-add-cleanup-if-needed (archive) which says "you need to cleanup the thing yourself". web.archive.org/web/20240720100401/https://react.dev/learn/synchronizing-with-effects#subscribing-to-events is also says that for the specific case of
addEventListener
.But that's annoying! Can't we just somehow tell if we applied twice or not to avoid having to implement a cleanup? What if a third party system does not provide a cleanup at all?
Is the correct solution to just just have a
useEffect
with empty dependency list? Seems to be good according to posts and to ESLint!Bibliography:
nodejs/next/posts Created 2024-08-27 Updated 2025-07-16
The goal of this example is to understand when states and effects happen when changing between different routes that use the same component.
Behavior is follows:
- visit: localhost:3001/1
- click
count++
. This makescount: 1
- click "2" to visit localhost:3001/2
- outcome: count is still 1
This is likely because in React the state kept in the virtual DOM structure, and identical structure implies identical state. So when we change from post 1 to 2, we still have a
Post
object, and state is unchanged.Next if we click:then the count is back to 0. This is because we changed the
- "Index" to go to localhost:3000
- "1" to go to localhost:3001/1
Post
object in the DOM to Index
and back, which resets everything.This example also illustrates how to prevent this from happening with
useEffect
. Conditional in semantic triple Created 2024-08-27 Updated 2025-07-16
react/ref-twice.html Created 2024-08-27 Updated 2025-07-16
Failed attempt at minimizing nodejs/next/ref-twice outside of Next.js.
Tempo Rei (documentary) Created 2024-08-27 Updated 2025-07-16
Very good documentary!
This is a documentary about Gilberto Gil going back to his homelnd for the first time since he emigrated to Salvador/Rio, with some of his most popular songs intermixed into it. Beautiful!
Of particular note is the Video "Lamento Sertanejo scene from the 2002 documentary Tempo Rei".
Semantic triple HOWTO Created 2024-08-27 Updated 2025-07-16
React DOM manipulation Created 2024-08-27 Updated 2025-07-16
Web Ontology Language Created 2024-08-27 Updated 2025-07-16
LANL PF-4 Created 2024-08-27 Updated 2025-07-16
Hardened Intersite Cable System Created 2024-08-27 Updated 2025-07-16
ESLint Created 2024-08-27 Updated 2025-07-16
Gilberto Gil bibliography Created 2024-08-27 Updated 2025-07-16
Speech synthesis Created 2024-08-27 Updated 2025-07-16
Kernel space Created 2024-08-27 Updated 2025-07-16
User space Created 2024-08-27 Updated 2025-07-16
Neutron moderation Created 2024-08-27 Updated 2025-07-16
Neutrino emission on Earth Created 2024-08-27 Updated 2025-07-16
Because they interact weakly with matter and mostly just escape out of nuclear reactors, you can likely locate all nuclear reactors on Earth by measuring neutrino flows:The CIA must love that shit, they must have had it years prior to this public paper.
Safe Sign Technologies Created 2024-08-27 Updated 2025-07-16
2024: acquired by Thomson Reuters[ref]
JavaScript linter Created 2024-08-27 Updated 2025-07-16
Unlisted articles are being shown, click here to show only listed articles.