Reputation: 385
I have developed my own website and have errors using react hook. The errors are like below.
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app
And here is my code:
import React from 'react';
import { useSelector } from 'react-redux';
import 'bootstrap/dist/css/bootstrap.min.css';
const ProfileEditing = ({
}) => {
const user = useSelector(state => state.auth);
console.log(user);
return (
<section className="dashboard">
<div className='side'>
<h1 className="large text-primary">Dashboard</h1>
<p className="lead">
</div>
</section>
);
};
export default ProfileEditing;
I try to fix it but doesn't work at all. Please help me.
Upvotes: 0
Views: 173
Reputation: 385
I fixed error.
The problem is not because of code but because of node_modules
.
I removed package-lock.json
and node_modules
and reinstall it.
And it works now.
Upvotes: 1