yesmeck / react-with-hooks

[OUTDATED]Ponyfill for the React Hooks API (Support RN)
https://codesandbox.io/s/olx6zp44n6
MIT License
152 stars 11 forks source link

useContext doesn't always correctly rerender #3

Closed janpaul123 closed 5 years ago

janpaul123 commented 5 years ago

Specifically, when you have a nesting like this: Provider -> SomeComponent -> ComponentWithUseContext where SomeComponent has shouldComponentUpdate = () => false; then ComponentWithUseContext doesn't properly rerender when Provider gets a new value (whereas using <Consumer> does rerender in that case).

yesmeck commented 5 years ago

Unfortunately, after hours trying, I could not find a proper way to implement useContext.

yesmeck commented 5 years ago

Finally, I figured it out.

janpaul123 commented 5 years ago

Wow amazing, nice work!! Thank you!