lundi 1 novembre 2021

Why is the state undefined in redux

I am trying to get some data from a reducer in redux and when I get the state using useSelector it return undefined I have tried to use console.log to log the data as well seeking help from other stackoverflow posts can anyone help?

Thanks!

Code:

import foo from "foo";
import React from "react";
import useSelector from "react-redux";

function fooBar():React.FC {
let data = useSelector(state:StateType=>{state.fooBar});
return(
<div>
<p>{data}</p>
</div>
);
}



Aucun commentaire:

Enregistrer un commentaire