atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.15k stars 43 forks source link

Add new hooks from React 18 #84

Open efoken opened 2 years ago

efoken commented 2 years ago

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

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.

UpperCod commented 2 years ago

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