Home > Mobile >  Why are my react hooks not getting called?
Why are my react hooks not getting called?

Time:12-18

This segment of code was working as expected but now the react hooks are not getting called.

import { store } from "./home.store";

const Home = () => {
 const [state, setState] = useState({});

 console.log('###store', store)

 useEffect(() => {
   console.log('USE EFFECT CALLED')
   console.log('state 1', store.getState());
   setState(store.getState());
 }, []);

 console.log("state 2", state);

 console.log('state 3', store.getState());
 setState(store.getState());
 console.log("state 4", state);

return (...)

Within the useEffect function, 'USE EFFECT CALLED' is never logged to the console. state 1 is never logged.

state 2 shows an empty object. state 3 correctly logs objects from the redux store. state 4 shows an empty object.

It appears useEffect and useState are not working. They worked previously.

CodePudding user response:

Looking at your code enter image description here

  • Related