react-loosely-lazy icon indicating copy to clipboard operation
react-loosely-lazy copied to clipboard

WIP: Support React 18

Open albertogasparin opened this issue 2 years ago • 0 comments

This is still a WIP branch, but the library now works properly with React 18, both in createRoot and hydrateRoot modes, and StrictMode too. I had to refactor some of the logic to not leverage anymore on the placeholders re-rendering, as if that happens R18 hydration process bails out and goes back to fallback (related issue ).

This actually poses an interesting dilemma, as our controlled phases are in reality discouraged by React team itself, as they poses risk of broken hydration if context data (for instance) changes before hydration occurs. So I think it might be beneficial to resume the work on https://github.com/atlassian-labs/react-loosely-lazy/pull/73 and migrate to that so we shorten the time for afterPaint to click in.

Anyway, I'm planning to backport some of the changes (for instance StrictMode support, examples, subscriptions refactor, ...) to the current branch so the diff here will become much smaller and manageable.

Lastly, I'ver dropped from this branch support for React 17 and lower. We could to either publish this as v2 (only R18+ compatible) or keep the old code in branches by detecting older versions of React. What do you think?

Todo:

  • [ ] Update tests
  • [ ] Backport StrictMode compliance to master
  • [ ] Decide if we want backward compat

albertogasparin avatar Mar 24 '22 05:03 albertogasparin