ctrlplusb / react-async-component

Resolve components asynchronously, with support for code splitting and advanced server side rendering use cases.
MIT License
1.45k stars 62 forks source link

Solved : Flashing LoadingComponent and render twice #81

Open Aetherall opened 6 years ago

Aetherall commented 6 years ago

I post this here in case someone encounter the issue

you need to set window.ASYNC_COMPONENTS_STATE before your script tag pointing to /main.js

seems logic but i lost 15mn with this ><

<html>
    <body>
        <div id="root">${html}</div>
        <script type="text/javascript">
            window.ASYNC_COMPONENTS_STATE = ${serialize(asyncState)}
        </script>
        <script type="text/javascript" src="/main.js"></script>
    </body>
</html>

Hope it helps someone