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

suggestion on how to fix the casting problems #10

Closed jarlah closed 5 years ago

dai-shi commented 5 years ago

Hi, I appreciate for your consideration. Not being sure if I understand the comments over time in #8, how much does this solve your issue?

My intuition for this PR is a bit hesitation. If the issue is about TypeScript type inference which might be improved in the future, I don't want to change index.js. Type casting should be better.

jarlah commented 5 years ago

Ill test the reducer cast :) maybe i didnt like casting the function. Casting parameters is more logical. And more readable. I think.

jarlah commented 5 years ago

ill use the function cast :)

dai-shi commented 5 years ago

Glad to hear that.

maybe i didnt like casting the function. Casting parameters is more logical.

Just a note: I would like to avoid casting at all if possible. Casting is just an escape hatch. I tried hard to make the Enhancer type compatible with Redux, but it wasn't successful.

jarlah commented 5 years ago

Casting to supported type is ok i think. Casting to any is no no. If i try to cast it to String i get error. So there is safety here. :) but anyway we can continue discussion in the open issue