The error: Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop. occurred after...
I changed my code from this:
if(location.state.name !== undefined || location.state.Username !== undefined){
console.log(location.state.name);
} else{
console.log("Nothing");
}
to this:
if(location.state.name !== undefined || location.state.Username !== undefined){
setName(location.state.name);
} else{
console.log("Nothing");
}
Where name, setName are empty useState string, and after setting name value as location.state.name which is a string that contains a username.