developit / unistore

🌶 350b / 650b state container with component actions for Preact & React
https://npm.im/unistore
2.86k stars 139 forks source link

WIP fix #171 Convert react integration to use hooks #186

Open lkmill opened 4 years ago

lkmill commented 4 years ago

To fix #171 and not use any UNSAFE_ methods, i converted the react integration to use hooks.

I haven't updated the tests yet, want to hear whether this is an acceptable change first.

Besides removing the warnings, this also greatly reduces the build file sizes:

Before:

Build "unistore" to .:
        620 B: react.js.gz
        531 B: react.js.br
Build "unistore" to full:
        801 B: react.js.gz
        708 B: react.js.br
        809 B: react.es.js.gz
        717 B: react.es.js.br
        861 B: react.umd.js.gz
        757 B: react.umd.js.br
Build "unistore" to .:
        466 B: react.js.gz
        393 B: react.js.br
Build "unistore" to full:
        682 B: react.js.gz
        592 B: react.js.br
        694 B: react.es.js.gz
        616 B: react.es.js.br
        741 B: react.umd.js.gz
        649 B: react.umd.js.br

With some code golf, eg not using array destructuring, it is quite simple to reduce the size further but the code becomes less readable.

ForsakenHarmony commented 2 years ago

Super old PR lol 🙃