diff --git a/packages/sitecore-jss-react/src/components/SitecoreContext.tsx b/packages/sitecore-jss-react/src/components/SitecoreContext.tsx index d9efa4bf30..9c543e590d 100644 --- a/packages/sitecore-jss-react/src/components/SitecoreContext.tsx +++ b/packages/sitecore-jss-react/src/components/SitecoreContext.tsx @@ -68,7 +68,13 @@ export class SitecoreContext extends React.Component { // we force the children of the context to re-render when the context is updated // even if the local props are unchanged; we assume the contents depend on the Sitecore context - this.contextFactory.subscribeToContext(() => this.forceUpdate()); + this.contextFactory.subscribeToContext(this.contextListener); + } + + contextListener = () => this.forceUpdate(); + + componentWillUnmount() { + this.contextFactory.unsubscribeFromContext(this.contextListener); } render() {