Skip to content

react@next changed behavior of invalid hook call message #3394

@eps1lon

Description

@eps1lon

Environment

Codesandbox with
styled-components: 5.2.1
react: 0.0.0-dc27b5aaa (current react@next)

Reproduction

https://codesandbox.io/s/invalid-hook-call-consoleerror-o0cvq?file=/src/index.js

Steps to reproduce

Create a styled-component

Expected Behavior

No console.error call

Actual Behavior

console.error logs:

Warning: 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:
1. You might have mismatching versions of React and the renderer (such as React DOM)

2. You might be breaking the Rules of Hooks

3. You might have more than one copy of React in the same app

See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

Context

React recently switched from throwing an error with this message to logging it with console.error: facebook/react#20604

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