Skip to content
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

Hooks not working due to Invalid Hook Call #1338

Open
ojnoonan opened this issue May 6, 2024 · 3 comments
Open

Hooks not working due to Invalid Hook Call #1338

ojnoonan opened this issue May 6, 2024 · 3 comments

Comments

@ojnoonan
Copy link

ojnoonan commented May 6, 2024

Steps to reproduce

  1. Install the react-rails gem version 3.2.0
  2. Try implementing hooks in functional component

Expected behavior

Hooks should be working as expected without getting the Invalid Hook Call error

Actual behavior

Got the Invalid Hook Call error breaking the page.

System configuration

  • Shakapacker or Sprockets version: sprockets-rails 3.4.2
  • React-Rails version: react-rails 3.2.0
  • React_UJS version:
  • Rails version: 5.2.8.1
  • Ruby version: 2.7.8

I'm trying to use hooks within my rails project. I have been successfully using react-rails within the asset pipeline without webpacker. When I create a react class I use extends React.Component without the need to import anything. When I try to implement any form of hooks using React.useState(""), it gives me the Invalid Hook call console error. I've checked the requirements for this error and I seem to be doing everything correctly.

@justin808
Copy link
Collaborator

@ojnoonan
Copy link
Author

@ojnoonan are you open to trying https://github.com/shakacode/react_on_rails?

Hey @justin808, the current project doesn't have support shakapacker or webpacker which appears to be a prerequisite of react_on_rails. I'm trying to get react_rails working with hooks but if I can't I'll have to wait until the project is updated to rails 7

@Judahmeek
Copy link
Collaborator

@ojnoonan we currently don't guarantee that hooks will work with the Sprockets implementation.

According to #984, hooks only works with the webpacker implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants