I get an warning when add a case : DELETE_SECRET
in store redux
const mySecretsReducer = (state = initialState, action) => {
switch (action.type) {
case GET_MY_SECRETS:
return {
items: action.payload
}
case DELETE_SECRET:
return {
items: state.items.filter(e => e.id !== action.payload.id)
}
default:
return state;
}
}
after delete an element, i get warning:
index.js:1 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in index (created by ConnectFunction)
in ConnectFunction (at TopSecret/index.js:12)
in div (at Top/index.js:11)
in div (at Top/index.js:8)
in index (at One/index.js:21)
in div (at One/index.js:20)
Here is my func setState in component i were deleted
deleteMySecret = () => {
let params = {
id: this.props.id
}
this.props.deleteMySecret(params)
.then(res => {
console.log(res.response);
this.setState({ showPopConfirm: !this.state.showPopConfirm });
}
)
.catch(res => {
console.log(res.response);
this.setState({ showPopConfirm: !this.state.showPopConfirm })
}
)
}
changeStatePopConfirm = () => {
this.setState({ showPopConfirm: !this.state.showPopConfirm })
}
How can i fix it.