-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why react-rails can not work with react context API? #984
Comments
I would be keen to help work adding support for hooks but don't really know where to start - anybody got any ideas? |
Hooks and context api happen within the JS context. This issue is likely not related to react-rails. Looking at the original question the OP could be using an old version of React if they're using Sprockets (They didn't specify) that doesn't have hooks. @mischa-s the best way to contribute to this specific issue would be to replicate this issue in a new project and link it to this issue so we can start to diagnose it more fully. Thank you for the assistance, it can take me a long time to get around to solving issues on topics I don't personally use otherwise. |
+1. Running into this issue with Sprockets while trying to use Hooks. I'm on React 16.9.0 (v2.6.1). Could be related to facebook/react#13991 |
Is this issue specific to Context or are all hooks not supported, because I ran into the same issue while using other hooks. EDIT: |
Closing this issue as it was fixed. |
react-rails can not re-render provider new state in children, also can not work with useContext in react
Contributing Guide
Steps to reproduce
<%= react_component("Test")%>
Test.js
context.js
demo.js
Expected behavior
Work with useContext and children can re-render when provider state is updated
Actual behavior
react.development.js:88 Uncaught Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
System configuration
Sprockets or Webpacker version: 3.5
React-Rails version: 2.4.4
Rect_UJS version: 2.4.4
Rails version: 5.2
Ruby version: 2.3.6
(Describe your issue here)
The text was updated successfully, but these errors were encountered: