TypeError: Cannot read properties of null (reading 'useContext') #64887
Unanswered
Abulkalam-Asif
asked this question in
Help
Replies: 1 comment
-
Transform Your Code From This
export default function RootLayout({ children }) {
return (
<>
<StoreProvider>
<AlertProvider>
<html lang="en">
<body className={roboto.className}>{children}</body>
</html>
</AlertProvider>
</StoreProvider>
</>
);
} To This And Check export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={roboto.className}>
<StoreProvider>
<AlertProvider>{children}</AlertProvider>
</StoreProvider>
</body>
</html>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Please help me resolve this problem.
I am working on a Project in Next.js and have been facing this error and nothing is helping me resolve it.
Here is the
ReadyProjectClientPage.js
file mentioned in the error:The main issue is that I am unable to reproduce the problem. The error appears randomly, once in a few hours, mostly when I reload the page. After it appears, no matter how hard may I try to reproduce it, it would not reappear.
I have manually checked all the hooks and they are all directly inside React components.
Here is my
AlertContext.js
file:Here is my root
layout.js
file in which I have put theAlertProvider
:The versions of react and react-dom are both 18.
I visited the this link to React official site provided in the error description.
Under the Duplicate React section, it says:
I ran the command on my terminal and here is the result:
Then it says:
I tried it in my current Next.js project,in a new Next.js project, and in a new React.js project using vite.
I noticed that in any Next.js project,
window.React1
pasted innode_modules/react-dom/index.js
is not accessible in any component and returnsundefined
, soconsole.log(window.React1 === window.React2);
always returns false. However in the React project,window.React1
pasted innode_modules/react-dom/index.js
is accessible in React components and returns anobject
.I have also added
react
andreact-router-dom
topeer-dependencies
as mentioned in another answer.Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions