stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

Improve async component section #377

Closed stereobooster closed 5 years ago

stereobooster commented 5 years ago

Fixed async component section

stereobooster commented 5 years ago

cc @@theKashey @sjsyrek

stereobooster commented 5 years ago

We can add example of lazy hydration with something like Intersection Observer API as well.

theKashey commented 5 years ago

Provided code would not run 😭

theKashey commented 5 years ago

Here you go - https://codesandbox.io/s/using-persistent-promises-for-lazy-prerendered-dk949 There is one key difference - live could accept boolean or a promise - not a function, so it should be executed

<PrerenderedComponent live={live()}>
stereobooster commented 5 years ago

Ah yes I wrote first version of the code "plain", so it wasn't really a lazy loading it was executed immediately (I mean .load() method), so I thought you forgot to wrap it inside lambda (to make it lazy), but in this code it is not needed (and apparently it was wrong in the first place)