You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReact,{Component}from'react';importDataSourcefrom'../../services/dataSource';constWithSubscription=(WrappedComponent,selectData)=>{returnclassextendsComponent{state={data: selectData(DataSource,this.props),};componentDidMount(){// ... that takes care of the subscription...DataSource.addChangeListener(this.handleChange);}componentWillUnmount(){DataSource.removeChangeListener(this.handleChange);}handleChange=()=>this.setState({data: selectData(DataSource,this.props)});render(){const{ data, props }=this.state;return<WrappedComponentdata={data}{...props}/>;}};};exportdefaultWithSubscription;
using some kind of a handmade Data Store, with a subscription system
The text was updated successfully, but these errors were encountered: