Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render not updating DOM more than once given replacement with differences.

See original GitHub issue


  1. SSRing a trivial page (via preact-render-to-string in Deno).
  2. A JS script with a single call to hydrate the Index component is requested, bundled by the server, and served.
  3. The document body is hydrated given the Index component.
  4. A websocket is opened with the server and when any changes are made to any tsx file, it sends a message to the client (browser).
  5. The browser dynamically imports Index and the render function.
  6. The Index.tsx file is requested, bundled with preact and with the render function re-exported from the bundle, and served.
  7. The updated component is rendered to the document body.

The above render works one time. After that it no longer renders anything further. I am verifying that the component it is being supplied does indeed have the changes (minor changes, it doesn’t work with even a single letter change in a string) and matches the exact structure of the currently mounted DOM (because it is the same component) but for some reason the DOM is not updating. If I do the same thing with hydrate, it does update as many times as it is called, but only updates text nodes, as far as I can tell and does not render any HTML attribute changes. With hydrate being what it is though, this is not unexpected to me.

I would expect subsequent calls to render beyond the first to update the DOM tree of body with the changes made to that tree.

Note that the h function is made available via import in the websocket client file. Thus, it is from the same “instance” of preact in all cases. I tried the above with re-exporting h from the bundle as I do with render with no luck.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

JoviDeCroockcommented, Jan 23, 2022

Yes, the options hooks are a singleton tied to the render process.

papirocommented, Jan 19, 2022

OMG… that fixed it. I literally just imported render along with h and used it instead of a per-bundle render. Cheers! Thank you so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React.render replace container instead of inserting into
It replaces the contents of whatever element you render into. The best you can do for now is render the React component separately...
Read more >
How and when to force a React component to re-render
React automatically re-renders components, but what happens when a component is not updating as expected? Find out what you can do here.
Read more >
Reconciliation - React
This article explains the choices we made in React's “diffing” algorithm so that component updates are predictable while being fast enough for high-performance ......
Read more >
A Closer Look at ReactDOM.render - The Need to Know and ...
When a React element is updated, ReactDOM firstly updates the Virtual DOM. After that, the difference between the actual DOM and the Virtual...
Read more >
When does React re-render components? - Felix Gerschau
Therefore we have to be aware of the difference between native and virtual DOM updates. Read more about how this works in React's ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found