I have code something like this:
componentDidMount() {
const { account, columns } = this.state;
getDependencies(this.context.contextPath, account, columns ).then(response => {
const updated = response.columns;
const newDimensions = updated.filter(
({ dimensionId: id1 }) =>
!columns.some(
({ dimensionId: id2 }) =>
id2 === id1
)
);
let temp = columns.concat(newDimensions);
temp = _.sortBy(temp, ['orderNo']);
this.setState(
{
allowedPostingDimensions: response.allowedDimensions,
columns: temp,
account: response.glAccount,
isDependenciesLoaded: true,
}, this.handleItemChange
);
});
}
And after sorting the columns I get error and setting I get this error:
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.
If I don't sort columns (just add new columns) I will not get this errors.
I already have tried to create flag in state: isMounted: false. In componentDidMount set state isMounted = true and in componentWillUnmount: set state isMounted = false. This is not help to me.