You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
550 B
26 lines
550 B
// Before
|
|
class ExampleComponent extends React.Component {
|
|
// highlight-range{1-10}
|
|
componentWillMount() {
|
|
this.setState({
|
|
subscribedValue: this.props.dataSource.value,
|
|
});
|
|
|
|
// This is not safe; it can leak!
|
|
this.props.dataSource.subscribe(
|
|
this.handleSubscriptionChange
|
|
);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.props.dataSource.unsubscribe(
|
|
this.handleSubscriptionChange
|
|
);
|
|
}
|
|
|
|
handleSubscriptionChange = dataSource => {
|
|
this.setState({
|
|
subscribedValue: dataSource.value,
|
|
});
|
|
};
|
|
}
|
|
|