|
@ -10,12 +10,14 @@ class ExampleComponent extends React.Component { |
|
|
this.finalizeSubscription(); |
|
|
this.finalizeSubscription(); |
|
|
} |
|
|
} |
|
|
// highlight-line
|
|
|
// highlight-line
|
|
|
// highlight-range{1-9}
|
|
|
// highlight-range{1-11}
|
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
if (this.props.dataSource !== prevProps.dataSource) { |
|
|
if (this.props.dataSource !== prevProps.dataSource) { |
|
|
// Similar to adding subscriptions,
|
|
|
// Similar to adding subscriptions,
|
|
|
// It's only safe to unsubscribe during the commit phase.
|
|
|
// It's only safe to unsubscribe during the commit phase.
|
|
|
prevProps.dataSource.dispose(); |
|
|
prevProps.dataSource.unsubscribe( |
|
|
|
|
|
this.handleSubscriptionChange |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
this.finalizeSubscription(); |
|
|
this.finalizeSubscription(); |
|
|
} |
|
|
} |
|
|