wingkwong / react-quiz-component

:orange_book: React Quiz Component
https://wingkwong.github.io/react-quiz-component/
MIT License
379 stars 147 forks source link

In version 0.8.2 it throw error Cannot read properties of null (reading 'useState') #309

Closed IamAhsanMani closed 1 month ago

IamAhsanMani commented 2 months ago

I want to use this package in my project but don't know why it throw error Cannot read properties of null (reading 'useState').

I even try it on codesandbox. here is codsandbox link https://codesandbox.io/p/sandbox/beautiful-austin-vdk8cp?workspaceId=7fe15d62-b82e-4f84-82f1-c0f57b4367e3

In version ^0.2.6 it work like here https://codesandbox.io/p/sandbox/magical-quiz-xt2l1

wingkwong commented 2 months ago

couldn't access the first sandbox

image

IamAhsanMani commented 2 months ago

@wingkwong try now link updated.

https://codesandbox.io/p/sandbox/beautiful-austin-vdk8cp?workspaceId=7fe15d62-b82e-4f84-82f1-c0f57b4367e3

IamAhsanMani commented 2 months ago

@wingkwong is bug find out. Because urgently need this package to use in my project.

wingkwong commented 2 months ago

I haven't checked in depth. Just skimmed through once, have you tried bumping your react version? Currently 0.8.2 is using react ^18.2.0 while your sandbox is still using 16. Also same for react-dom.

IamAhsanMani commented 1 month ago

Hello @wingkwong as you said i upgraded by project packages to latest versions.

Here is my package.json

package

But there is still same useState error

Screenshot 2024-09-21 at 2 54 58 PM

Don't know what is the issue if you please help me out it would be great

wingkwong commented 1 month ago

I didn't see the error in your updated sandbox.

IamAhsanMani commented 1 month ago

@wingkwong No the error is generating in my local project.

wingkwong commented 1 month ago

The reported issue was due to the outdated react version, which was proven after you upgraded the version in the sandbox. I can't really help if this happens in your local project. Probably you may cross check with the sandbox one to see the difference or try remove node_modules and reinstall again.

IamAhsanMani commented 1 month ago

Issue resolved by upgrading to react and react-dom latest version and plus make sure to clear cache and node_module and reinstall.