scio-labs / use-inkathon

Typesafe React hooks and utility functions that simplify the process of working with Substrate-based networks and ink! smart contracts.
https://inkathon.xyz
GNU General Public License v3.0
49 stars 15 forks source link

Consider State Management solution to refactor `useInkathon` into smaller hooks #6

Open wottpal opened 1 year ago

nicolad commented 1 year ago

is this still relevant, since u already use context API from react?

wottpal commented 1 year ago

Yep, as i can't easily access this provider context outside hooks.. and it's already huge right now and i see no straightforward way splitting it up w/o using some other state management solution.

nicolad commented 1 year ago

Have you used smth like recoil?

https://recoiljs.org/

I am using react-query and react-hook-form in prod, so I don't really need dedicated state management.

jalooc commented 1 year ago

Hey, sleek lib @wottpal, well done 👍 Looking forward to trying it out.

In terms of React state management solutions in which you want an ability to access state outside of hooks, or even React components, I can recommend https://github.com/pmndrs/zustand - really simple to use and similar to Redux in principles, but without its boilerplate.

wottpal commented 1 year ago

Thanks so much @jalooc. Would really love to hear more about your experience with the lib or in general what you are up to in the ink! space :) (We also have a tg group https://t.me/inkathon).

And I know Zustand and it's awesome! Recently I've also started using https://jotai.org/ which is dope as well, even though it follows a different paradigm than Zustand/Redux.

niklasp commented 3 months ago

i wouldn't introduce a state management library and leave that to the users. let's rely solely on react context for state management. in my former apps i was separating my providers into two internally:

  1. extension provider (browser extension related stuff: accounts, activeAccount, signer, ...)
  2. chain provider (polkadot api related stuff: api, activeChain, switchActiveChain)