A
A
andreys752021-08-24 23:24:48
React
andreys75, 2021-08-24 23:24:48

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


the same error is thrown on any hook

1, I use hooks correctly at the main component level
2, I connect React once
3, I checked the versions of react and react home
[email protected]% npm ls react
[email protected]  ******
└── [email protected] 

[email protected]% npm ls react-dom
[email protected] ******
└── [email protected]


here is the simplified code of the main component
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>}
    


    </>
  )


}


I tried to transfer react in package.json and react house in peerDependancy , webpack added externals.
Unfortunately I haven't found a solution yet.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question