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.

null is not an object (evaluating 'dispatcher.useState') with RN 0.68.1

See original GitHub issue

Steps to reproduce

  1. create a bare RN app with npx react-native init DripsyTest
  2. Install Dripsy npm install dripsy --save
  3. npm start and npm run ios
  4. Replace App.js code with:
import React from 'react';
import {DripsyProvider, makeTheme, View} from 'dripsy';

const theme = makeTheme({});
export default function App({Component, pageProps}) {
  return (
    <DripsyProvider theme={theme}>
      <View />
    </DripsyProvider>
  );
}

Expected result

App starting successfully

Actual result

Simulator Screen Shot - iPhone 13 - 2022-05-03 at 10 09 06

 ERROR  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.
DripsyProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:116768:30
App@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:111689:25
RCTView
View
RCTView
View
AppContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:78446:36
DripsyTest(RootComponent)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:85130:28
 ERROR  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.
DripsyProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:116768:30
App@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:111689:25
RCTView
View
RCTView
View
AppContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:78446:36
DripsyTest(RootComponent)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DripsyTest:85130:28
 ERROR  TypeError: null is not an object (evaluating 'dispatcher.useState')

This error is located at:
    in DripsyProvider (at App.js:7)
    in App (at renderApplication.js:50)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:92)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:43)
    in DripsyTest(RootComponent) (at renderApplication.js:60)
 ERROR  TypeError: null is not an object (evaluating 'dispatcher.useState')

This error is located at:
    in DripsyProvider (at App.js:7)
    in App (at renderApplication.js:50)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:92)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:43)
    in DripsyTest(RootComponent) (at renderApplication.js:60)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nandorojocommented, May 14, 2022

i assume you’re using npm. try using legacy peer deps

0reactions
t3chcrazycommented, May 14, 2022

This worked for me, thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError dispatcher.useState is not a function when using ...
as I want to try out the new React hooks proposal by installing react@16.8.1 in my package.json , but I'm getting an error:...
Read more >
null is not an object (evaluating e.endCoordinates) #31 - GitHub
Bug I use useKeyboard hook, and when the keyboard is closing I got an error null is not an object (evaluating e.endCoordinates).
Read more >
TypeError: dispatcher.useState is not a function for React ...
Coding example for the question TypeError: dispatcher.useState is not a function for React Native-React Native.
Read more >
Hooks API Reference - React
Unlike the setState method found in class components, useState does not automatically merge ... Accepts a context object (the value returned from React....
Read more >
How to use React useReducer hook like a pro - Devtrium
We'll learn about how dispatch works later on. ... While the useState version is probably familiar to you (if not, it might be...
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