The problem
In dev mode, AppRegistry.runApplication replaces the children of the target DOM node as expected. In prod mode, however, the react app is appended to a nested DOM element.
How to reproduce
Simplified test case:
Dev: https://codesandbox.io/s/issue-react-native-for-web-g512l
Prod: https://csb-g512l.netlify.com/
Steps to reproduce:
Expected behavior
I expect the DOM element's children to be replaced, not appended. As it does in dev.
Environment (include versions). Did this work in previous versions?
I'm trying to create a loading screen using DOM elements in the index.html file.
That's probably down to this line and ReactDOM leaving existing HTML alone when hydrating
What I think I'll do is add a field hydrate to the application params, and that can be used on the client to opt into hydrating the app if you know you server rendered.
ApplicationRegistry.runApplication('App', {
initialProps: {},
rootTag: document.getElementById('root'),
hydrate: true
});
Any progress with this issue?
This change is in master if you want to try it out before I cut a pre-release version that includes it
Most helpful comment
What I think I'll do is add a field
hydrateto the application params, and that can be used on the client to opt into hydrating the app if you know you server rendered.