Browse Source

fix(ui): Prevent guides from updating state before mount (#67213)

Scott Cooper 11 months ago
parent
commit
bb78ae9c0f
1 changed files with 7 additions and 5 deletions
  1. 7 5
      static/app/components/assistant/guideAnchor.tsx

+ 7 - 5
static/app/components/assistant/guideAnchor.tsx

@@ -83,18 +83,20 @@ class BaseGuideAnchor extends Component<Props, State> {
   componentDidMount() {
     const {target} = this.props;
     registerAnchor(target);
+    this.unsubscribe = GuideStore.listen(
+      (data: GuideStoreState) => this.onGuideStateChange(data),
+      undefined
+    );
   }
 
   componentWillUnmount() {
     const {target} = this.props;
     unregisterAnchor(target);
-    this.unsubscribe();
+    this.unsubscribe?.();
   }
 
-  unsubscribe = GuideStore.listen(
-    (data: GuideStoreState) => this.onGuideStateChange(data),
-    undefined
-  );
+  // TODO(TS): Reflux returns "Function" instead of () => void
+  unsubscribe: Function | undefined;
 
   onGuideStateChange(data: GuideStoreState) {
     const active =