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

React 16.8.1 causing useContext error log #5

Closed AndiF closed 5 years ago

AndiF commented 5 years ago

With React 16.8.1 I noticed the following error log: Warning: useContext() second argument is reserved for future use in React. Passing it is not supported.

I am not sure about the intention of the 2nd parameter here: const state = useContext(context, 1 << index); but I guess it can simply be removed ?

malerba118 commented 5 years ago

Also encountering this

dai-shi commented 5 years ago

This is called observedBits which is undocumented and unstable.

Let's say we have a state like: { counter1: 0, counter2: 0 } and we useGlobalState('counter1') in a component "A". We want to avoid rendering A when only counter2 is updated, and that's how observedBits is currently used. It is supposed to be super efficient.

Now, since React 16.8 clearly warns the use of this, I'm wondering what I should do with it...

dai-shi commented 5 years ago

https://github.com/facebook/react/pull/14729#issuecomment-461279892 This is exactly the same here. Cc @gaearon @benwiley4000

gaearon commented 5 years ago

https://github.com/facebook/react/issues/14815#issuecomment-462194923

dai-shi commented 5 years ago

Ben and Dan, thanks so much! I will look into it.

dai-shi commented 5 years ago

Published v0.7.0.