I need to wait user data from auth0 api, to setState. I try to do this with componentDidUpdate, but i have an infinite loop What's wrong in this code ? :
class App extends React.Component {
constructor(props) {
super(props);
const { user } = this.props.auth0;
// Context state
this.state = {
races: {},
regions: {},
allAnnonces: {},
profile: {}
}
}
componentDidMount() {
const user = this.props.auth0.user;
console.log("componentDidMount",this.props.auth0.isAuthenticated);
}
componentDidUpdate(prevProps) {
const isAuthenticated = this.props.auth0.isAuthenticated;
if (prevProps.isAuthenticated != isAuthenticated) {
this.setState({ userInfos: "test" });
}
}
render() {
if (isLoading) {
return <Loading />;
}
return (
<>hello</>
)
}
Here the Auth0 props :
