Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
VisileanRushiC opened this issue Dec 20, 2023 · 2 comments

Comments

@VisileanRushiC
Copy link

VisileanRushiC commented Dec 20, 2023

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

Copy link

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

@VisileanRushiC
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant