Store
Store is observable object that holds all application state
Store can be accessed in one of 2 ways:
From Actions
Or directly Store.store - but in this case you are responsible for subscription management and view update
public todos: [];
componentDidMount() {
this.subscription = Store.store.select(['todos'])
.subscribe(state => {
this.todos = state; // OR this.todos = state.toJS()
this.forceUpdate();
})
}
componentWillUnmount() {
this.subscription.unsubscribe();
}
render() {
return (
<div>{this.todos.getIn([0])}</div>
)
}
TIP: try to avoid .toJS() calls because it is not the best practice and is might be costly performance vise.
Last updated
Was this helpful?