dai-shi / react-hooks-global-state

[NOT MAINTAINED] Simple global state for React with Hooks API without Context API
https://www.npmjs.com/package/react-hooks-global-state
MIT License
1.1k stars 62 forks source link

shall we setState like native hook? #22

Closed piggyman007 closed 5 years ago

piggyman007 commented 5 years ago

shall we setState like native hook?

e.g.,setData(newData) instead of

setData(v => newData)

dai-shi commented 5 years ago

Yes, both are possible.

https://github.com/dai-shi/react-hooks-global-state/blob/7b2f10083fe842ed0b44fd6d2a4333efe9126811/examples/01_minimal/src/index.js#L17

https://github.com/dai-shi/react-hooks-global-state/blob/7b2f10083fe842ed0b44fd6d2a4333efe9126811/examples/02_typescript/src/Counter.tsx#L10

piggyman007 commented 5 years ago

Thanks for the response. I have added more example in the readme file, please merge my PR. @dai-shi

dai-shi commented 5 years ago

Merged. Thanks. Look forward to more feedbacks.