From 4744caab77c19e9981d88d221851f541ac199d46 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 27 Oct 2016 15:31:27 -0700 Subject: [PATCH] fix(tooltips): comp. w/ tooltip must be conditionally rendered Also update tooltips to support functional components. --- .../decorators/has-tutorial-tip.jsx | 24 +++++++++---------- src/pro | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/decorators/has-tutorial-tip.jsx b/src/components/decorators/has-tutorial-tip.jsx index 4ba4a77f2..aad41dce5 100644 --- a/src/components/decorators/has-tutorial-tip.jsx +++ b/src/components/decorators/has-tutorial-tip.jsx @@ -104,11 +104,14 @@ class TipPopoverContents extends React.Component { export default function HasTutorialTip(ComposedComponent, TipConfig) { const TipKey = ComposedComponent.displayName; + if (!TipKey) { + throw new Error("To use the HasTutorialTip decorator, your component must have a displayName."); + } if (TipsStore.hasSeenTip(TipKey)) { return ComposedComponent; } - return class extends ComposedComponent { + return class extends React.Component { static displayName = ComposedComponent.displayName; constructor(props) { @@ -118,10 +121,6 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) { } componentDidMount() { - if (super.componentDidMount) { - super.componentDidMount(); - } - TipsStore.mountedTip(TipKey); this._unlisteners = [ @@ -153,20 +152,13 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) { this._onTooltipStateChanged(); } - componentDidUpdate(...args) { - if (super.componentDidUpdate) { - super.componentDidUpdate(...args); - } + componentDidUpdate() { if (this.state.visible) { this._onRecomputeTooltipPosition(); } } componentWillUnmount() { - if (super.componentWillUnmount) { - super.componentWillUnmount(); - } - this._unlisteners.forEach((unlisten) => unlisten()) this._disposables.forEach((disposable) => disposable.dispose()) @@ -261,5 +253,11 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) { } attempt(); } + + render() { + return ( + + ); + } } } diff --git a/src/pro b/src/pro index a35be90c3..88f3dc53e 160000 --- a/src/pro +++ b/src/pro @@ -1 +1 @@ -Subproject commit a35be90c3c316c2467bb577dade5f6738799f84d +Subproject commit 88f3dc53e3fca98ac91ff4c6da6e7ff6e5493902