importReact,{useContext}from'react';import{UserContext}from'./context';constPanel=()=>{const{ user }=useContext(UserContext);return(<p>{user}</p>)}exportdefaultPanel
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:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app
Hooks and context api happen within the JS context. This issue is likely not related to react-rails.
Basically if it works in Webpack it will work in this gem broadly speaking.
@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.
Is this issue specific to Context or are all hooks not supported, because I ran into the same issue while using other hooks.
I want to know if its a problem with my implementation or does hooks generally not work with react-rails.
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: