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.

Cannot read properties of null (reading 'useRef')

See original GitHub issue

Not sure this is the correct place to ask, but I have some issues with using Moti when building both to simulator and to real device.

Specs:

  • MacBook Pro 2021 (M1 processor)
  • React: 17.0.2
  • React Native: 0.66.0
  • Moti: 0.17.1

The app crashes with an error saying:

  • “Cannot read properties of null (reading ‘useRef’)”
  • “Cannot read properties of null (reading ‘useContext’)”

image

It seems to be related to AnimatePresence. When looking into the code it seems like it’s coming from: node_modules/@motify/core/node_modules/react/cjs/react.development.js (Row: 1623)

Worth mentioning is that it work for me previously, but I did a clean install of the repo and since then this issue keeps occuring.

Tried what I could think of:

  • rm -rf node_modules/
  • pod deintegrate
  • npm i
  • pod install
  • Making sure that all metro bundlers are closed
  • Clean build folder
  • Turning of remote debugging
  • npm cache clear --force
  • npm start

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
Niklas-Liljendahlcommented, Apr 11, 2022

Managed to get it to work with: npm i --legacy-peer-deps

Thanks a lot!

4reactions
nandorojocommented, Jul 18, 2022

Yeah I see. So your version of npm automatically installs peer deps. if you use the npm legacy peer deps feature it should fix it. or, set a resolution of react to 17.0.2 inside or your package.json.

Plainly, you should only use one version. Using yarn would also solve this.

npm i --legacy-peer-deps

Or, in your root package.json, add a resolution:

{
  "resolutions": { "react": "17.0.2" }
}

If you do this, you need to use yarn (or install an npm tool to do it for you). Make sure you set 17.0.2 to whichever version you actually want to use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read properties of null (reading 'useRef')
I'm using Next.js, TypeScript, sanity and tailwindcss. Im trying to use the react-hook-form but i receive an error. I've tried: changing the ...
Read more >
react cannot read properties of null - You.com | The AI Search ...
ReactJS: TypeError: Cannot read properties of null (reading 'useRef') ... The useRef Hook allows you to persist values between renders.
Read more >
Error trying to set up tests with Vitest. TypeError - Reddit
Error trying to set up tests with Vitest. TypeError: Cannot read properties of null (reading 'useRef') ... It says it's happening in my...
Read more >
React useRef Hook - W3Schools
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are ...
Read more >
Cannot read properties of null (reading 'useRef') error-Reactjs
Coding example for the question Cannot read properties of null (reading 'useRef') error-Reactjs.
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