atomico icon indicating copy to clipboard operation
atomico copied to clipboard

Add new hooks from React 18

Open efoken opened this issue 3 years ago • 1 comments

React 18 introduced 5 new hooks which should be added to Atomico:

  • useTransition
  • useDeferredValue
  • useId
  • useSyncExternalStore
  • useInsertionEffect

As we share some code between React Native and Atomico, it would be nice to have the new hooks available. At least I wanted to use useId and useInsertionEffect which should be pretty easy to add I guess.

efoken avatar Jul 24 '22 12:07 efoken

Interesting, I have been reading the new React hooks and there is a big difference in Atomico and React task management

Atomico manages tasks like islands (webcomponent), so Atomico does not group tasks into a global funnel like React does.

image

This allows Atomico to render faster because components don't block each other. Another benefit of this is SSR hydration, as each component is hydrated when assembled.

I will review the new hooks in more detail, to understand their behavior well, I think that if it is possible to support useId and useInsertionEffect in the next version, I will work on them.

the challenges are:

useId

(React) useId is a hook for generating unique IDs that are stable across the server and client, while avoiding hydration mismatches.

useInsertionEffect, require modify render cycle

I will keep you informed on this issue

UpperCod avatar Jul 25 '22 18:07 UpperCod