DEV Community

Discussion on: I need help. TypeError: Cannot read properties of undefined (reading 'current')

Collapse
 
murashow profile image
Makar Murashov

Prop loading that you're passing to your component is undefined somehow, I believe it is a ref for something, please check if you really initialized it correctly. It might be undefined on initial load somehow.
Other thing - you could add the Optional Chaining operator there to prevent this error:

if (loading?.current && showScore) {}
Enter fullscreen mode Exit fullscreen mode