Skip to content

App breaks after root update if rendered with replaceNode #2260

@xkam

Description

@xkam

I'm having issue with render replaceNode parameter - the app breaks after I run render the second time with updated properties for the root component. Unfortunately I could not isolate the problem, the simple cases work as intended, so the issue might well be in my code. The first error is indeed in my code, but it looks that it's because something else is broken.

This works fine (1) - https://codepen.io/activewidgets/pen/YzPJebK

render(h(App, initialProps), container);
setTimeout(() => render(h(App, updatedProps), container), 100);

This breaks (2) - https://codepen.io/activewidgets/pen/OJPBQKX

render(h(App, initialProps), container, target);
setTimeout(() => render(h(App, updatedProps), container, target), 100);

I've found that this one actually works too (3) - https://codepen.io/activewidgets/pen/eYmPVqK

render(h(App, initialProps), container, target);
setTimeout(() => render(h(App, updatedProps), target), 100);

Full code (static page) - https://gist.github.com/xkam/098b970d3cbc43427f764491f10dfea1

The variant (3) does what I want, so I'm fine if this is an intended use, but from the docs I had the impression that the right one is (2), and that one breaks.

Sorry, the examples have layers of other (less then ideal) code, but I thought that it might be useful anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions