Browse Source

Fixed small error in example

main
Brian Vaughn 7 years ago
parent
commit
858c1a7511
  1. 6
      examples/update-on-async-rendering/adding-event-listeners-after-continued.js

6
examples/update-on-async-rendering/adding-event-listeners-after-continued.js

@ -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();
} }

Loading…
Cancel
Save