localvoid / ivi

Lighweight Embeddable Web UI Library
MIT License
723 stars 22 forks source link

useEffect docs wrong? #51

Closed leeoniya closed 1 year ago

leeoniya commented 1 year ago

@localvoid

https://github.com/localvoid/ivi/blob/844aa0a7cc7fa87b11f825452f1cec857c5acea6/packages/ivi/README.md?plain=1#L925

mistake?

also, is useUnmount() identical to the cleanup function returned from useEffect()?

also (unrelated), i see that updateRoot() has been renamed update(), but the first arg is still called root. we also have createRoot(). feels like a naming inconsistency now?

the README still has updateRoot( in its examples

localvoid commented 1 year ago

mistake?

No, useEffect that doesn't depend on any inputs can be immediately invoked just once in the outer scope.

is useUnmount() identical to the cleanup function returned from useEffect() ?

Yes. useEffect() uses useUnmount() to add unmount hooks.

feels like a naming inconsistency now?

When I've reduced API surface a couple of days ago, I've made update(), dirtyCheck(), etc that used flags in their arguments as private and just renamed updateRoot() to update(). Personally, I don't care how this functions are named and I just didn't want to rename createRoot() to something like root() to make it more consistent.

And to make it more consistent with createRoot() it will be necessary to rename dirtyCheck, unmount, hydrate, update. I just wanted to keep it simple.