i have the following code
9 | const [personS, setpersonS] = useState([]);
10 | const [loaded, setloaded] = useState(false);
11 |
> 12 | let location = useLocation();
| ^ 13 | const linkFollowers =
14 | location && location.state && location.state.followers
15 | ? location.state.followers
but brings an error of "TypeError: Object(...) is not a function". Can anyone help me out on how to solve this.
CodePudding user response:
put it in a function like
const MyComp = (props) =>{
const [personS, setpersonS] = useState([]);
const [loaded, setloaded] = useState(false);
let location = useLocation(); //<--- put this in a Hook
}
export default MyComp
CodePudding user response:
try
const linkFollowers =location?.state?.followers || null || "something else"