aidenybai / million

Optimize React performance and make your React 70% faster in minutes, not months.
https://million.dev
MIT License
16.33k stars 573 forks source link

Error: Cannot read properties of null (reading 'useContext') in Scheduler Component #847

Closed VisileanRushiC closed 10 months ago

VisileanRushiC commented 10 months ago

What version of million are you using?

2.6.4

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Chrome

Describe the Bug

Issue Overview: I encountered an error while working with the Million library in the Scheduler component. The error message I received is:

"Cannot read properties of null (reading 'useContext') TypeError: Cannot read properties of null (reading 'useContext') at Object.useContext (http://takt.visilean.local:3000/static/js/bundle.js:266633:25) at useNavigate (http://takt.visilean.local:3000/static/js/bundle.js:256653:42) at Scheduler (http://takt.visilean.local:3000/static/js/bundle.js:72392:82) ... Description: I'm utilizing the Million library alongside other dependencies like '@shopify/react-web-worker', '@fullcalendar/react', 'contexts/SocketContext', and 'store/liveModeSlice' within my Scheduler component. The error seems to be related to the useContext hook and specifically arises in the useNavigate function call within the Scheduler component.

craco.config.cjs import { webpack as millionWebpack } from 'million/compiler';

module.exports = { webpack: { plugins: { add: [millionWebpack({ auto: true })] }, typescript: { enableTypeChecking: true } } };

Expected Result: I expect the Scheduler component to render without any errors related to the useContext hook and the useNavigate function. However, the current issue prevents the proper functioning of the Scheduler component due to the error mentioned above.

Steps to Reproduce: It seems the issue might be related to how the useContext hook is utilized in conjunction with the useNavigate function within the Scheduler component. Unfortunately, I am unable to identify the exact cause without more context or a reproduction scenario.

Additional Information:

Environment: [Specify relevant details about your environment, such as the browser, operating system, versions of libraries used, etc.] Code snippets: Provide any relevant code snippets from the Scheduler component or related components that might be contributing to this issue. Any help or insights on resolving this issue would be greatly appreciated!

What's the expected result?

The expected result would be the resolution of the reported error related to the useContext hook within the Scheduler component. This would allow the Scheduler to function correctly without encountering the 'Cannot read properties of null' error specifically linked to the useContext hook and useNavigate function.

Also, how can I check if the Automatic mode is working or not? @aidenybai @tobySolutions

github-actions[bot] commented 10 months ago

Thanks for opening this issue! A maintainer will review it soon.

VisileanRushiC commented 10 months ago

@tobySolutions & @aidenybai my app is up and running with Million. The steps I followed were: Step 1 Install Craco: npm i -D @craco/craco Step 2 Update the existing calls to react-scripts in the scripts section of your package.json to use the craco CLI: "start": "craco start"

After performing these steps my app got integrated with Million js.