Skip to content

Hooks not working due to Invalid Hook Call #1338

Open
@ojnoonan

Description

@ojnoonan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions