Pages switch back and forth in antd, setState reports an error

error message is
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.

The

step is:
there are two pages, an and b, which are table, of antd and render a button in column

<a key={"btn-delete"}  onClick={() => {
    this.setState({    
        b: Date.now()
    })
}}></a>

if you use this.props.history.push ("/ b") to jump to b, and then use this.props.history.push ("/ a") to jump to a, click Delete at this time, you will report this error, but if you refresh the page, you will not report an error.

seek the great god

Mar.03,2021
The hint of

is obvious, but there is no problem with your code.


your code has omitted the key part, this deletion should have a network asynchronous request. When the page is unloaded, execute setState and of course report an error

Menu