question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid hook call

See original GitHub issue

Describe the bug

const repeats = [
            {
                label: 'Never',
                value: 'none',
            },
            {
                label: 'Daily',
                value: 'daily',
            },
            {
                label: 'Weekly',
                value: 'weekly',
            },
            {
                label: 'Monthly',
                value: 'monthly',
            },
        ];

<RNPickerSelect
      placeholder={{}}
      useNativeAndroidPickerStyle={false}
      items={repeats}
      value={"daily"}
    />

I’m getting the following error:

Error: 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

This happened after upgrading the library to v8.0.4 and RN to 0.69.5.

To Reproduce
Steps to reproduce the behavior:

  1. Create a React component
  2. Put the code inside the render function
  3. Notice error

Expected behavior
The app shouldn’t crash.

Screenshots
N/A

Additional details

  • Device: Android
  • OS: Android 12
  • react-native-picker-select version: 8.0.4
  • react-native version: 0.69.5
  • expo sdk version: N/A

Reproduction and/or code sample
Not using expo.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Mridul2820commented, Sep 6, 2022

The issue is coming from @react-native-picker/picker

I just downgraded that package and it worked for me

Working Version - "@react-native-picker/picker": "^1.16.0",

0reactions
Nesh108commented, Sep 8, 2022

I ended up switching to another library which didn’t break.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Hook Call Warning - React
Hooks can only be called inside the body of a function component. There are three common reasons you might be seeing it: You...
Read more >
Invalid hook call. Hooks can only be called inside of the body ...
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the...
Read more >
Invalid hook call - How to resolve multiple versions of React ...
I noticed that whenever I link each individually, the former unlinks. So by doing npm link ./path-to-app/node_modules/react ./path-to-app/ ...
Read more >
Invalid hook call. Hooks can only be called inside of the body ...
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of...
Read more >
Invalid hook call. Hooks can only be called ... - Datainfinities
React error “Invalid hook call. Hooks can only be called inside the body of a function component” occurs due to many reasons. Learn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found