Answer the question
In order to leave comments, you need to log in
How to solve the problem with react hooks?
Good afternoon!
Got a project written in React with classes. With a clumsy component structure. And since it is necessary to write functionality, I started writing functional components using hooks
. The project build passes, but when I try to open the page, it gives an error
Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at P (/........ App.js:9:3759)
at t.useState
[email protected]% npm ls react
[email protected] ******
└── [email protected]
[email protected]% npm ls react-dom
[email protected] ******
└── [email protected]
import React, { useState } from 'react';
import './app.scss';
export default function App(){
// const [state, dispatch] = useReducer(stateReducer, initialState);
const [isLoading, setLoading] = useState(true);
const [error, setError] = useState({isError:false, message:''});
console.log(setLoading, setError);
return (
<>
{(isLoading || error.isError) && <div>Loading...</div>}
</>
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question