mweststrate / use-st8

Single-function alternative for React.useState
MIT License
234 stars 7 forks source link

feat: memoize function hook returns #17

Closed geakstr closed 2 years ago

geakstr commented 2 years ago

First of all — thanks for the clever idea @mweststrate!

Patch implements memoization for the returned function: creation of new function (and, accordingly, a new memory reference) only depends on internal state change and not from props outside of hook. This allows to avoid unnecessary rerenders of dependant react components.

mweststrate commented 2 years ago

Looking good! Thanks