Ich habe Formular, wo ich eines der Elemente in einer Weile rendern sollte. Ich benutze setTimeout
für dieses Ziel in componentDidMount
aber ich setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component.
Reaktion js Delay Rendering verursacht Fehler
class Form extends React.Component {
constructor(props, context) {
this.state = {resend: false};
}
componentDidMount() {
const max = 3;
if (this.props.count < max) {
setTimeout(() => {
this.setState({resend: true});
}, 1000);
}
}
render() {
return (
<form>
...
{this.state.resend ? <Component/> : null}
</form>
);
}
}
Vielen Dank! Es half mein Problem zu lösen – MyName