Skip to content

Memory leak from components not unsubscribing from redux store

Several components, e.g. CreateProject, EditProject and CreateTask, do not unsubscribe from the redux store, causing a memory leak. This can easily be remedied by subscribing to the store in the ComponentDidMount() function like the following:

componentDidMount() {
    this.unsubscribe = store.subscribe(() => { Function here }));
}

Unsubscribing can then be done from the store on ComponentWillUnmount(), like so:

ComponentWillUnmount() {
    this.unsubscribe();
}