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
import React from 'react';
import ExampleActions from '../alt/actions/ExampleActions';
import ExampleStore from '../alt/stores/ExampleStore';
class Example extends React.Component {
constructor(props) {
super(props);
this.updateStore = this.updateStore.bind(this);
this.storeChanged = this.storeChanged.bind(this);
this.state = {
data: ExampleStore.getData(),
};
}
componentWillMount() {
ExampleStore.listen(this.storeChanged);
}
componentWillUnmount() {
ExampleStore.unlisten(this.storeChanged);
}
storeChanged(exampleStoreState) {
this.setState({
data: exampleStoreState.getData(), // can't do this obviously
data: ExampleStore.getData(), // Is this guaranteed to have the updated state?
});
}
updateStore(object) {
ExampleActions.createData(object);
}
render() {
// contains button you click that triggers updateStore with some object
}
}
export default Example;
Question: when my listener gets fired, I wish to be able to use my public method instead of reading from the state directly. However, I am unsure that I am guaranteed ExampleStore itself has the updated. It seems to work, but I thought I would clarify so I don't get burned later.
Thanks.
The text was updated successfully, but these errors were encountered:
ExampleStore.js:
ExampleComponent.jsx:
Question: when my listener gets fired, I wish to be able to use my public method instead of reading from the state directly. However, I am unsure that I am guaranteed ExampleStore itself has the updated. It seems to work, but I thought I would clarify so I don't get burned later.
Thanks.
The text was updated successfully, but these errors were encountered: