Reputation: 131
using functional components to build out my ui. My register component cant find the import react, {useState} from 'react'
It gives me back this error.
Failed to compile.
./src/pages/Register.js
Line 10:31: React Hook "useState" is called in function "register"
which is neither a React function component or a custom React Hook function
react-hooks/rules-of-hooks
Search for the keywords to learn more about each error
I have deleted react and reinstalled it with no luck
import React, { useContext, useState } from "react";
function register() {
const initialState = {
username: "",
password: "",
confirmPassword: "",
email: "",
};
const [values, setvalues] = useState(initialState);
return (
<div>
<h1>register</h1>
</div>
);
}
export default register;
Upvotes: 0
Views: 867
Reputation: 369
Your problem is that components names must be capitalized in react. must be "Register" and no "register".
Upvotes: 5