Cannot read properties of null (reading 'useRef')
See original GitHub issueNot 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’)”
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:
- Created a year ago
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Managed to get it to work with:
npm i --legacy-peer-deps
Thanks a lot!
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.
Or, in your root
package.json
, add a resolution:If you do this, you need to use
yarn
(or install an npm tool to do it for you). Make sure you set17.0.2
to whichever version you actually want to use.