Skip to content

Instantly share code, notes, and snippets.

@suchitpuri
Created September 24, 2015 10:47
Show Gist options
  • Save suchitpuri/a4afbbc8aa07023d68b8 to your computer and use it in GitHub Desktop.
Save suchitpuri/a4afbbc8aa07023d68b8 to your computer and use it in GitHub Desktop.
Component Talking to Store in React + Flux
class LinkAccounts extends Component {
constructor(props) {
super(props);
this.state = this.getState();
this.state.pageLoading = 50;
this._onChange = this._onChange.bind(this);
LoaderStore.addChangeListener(this._onChange);
}
_onChange() {
this.setState(this.getState());
}
getState() {
return {
pageLoading: LoaderStore.getPageLoader(),
}
}
componentDidMount() {
LoaderActions.donePageLoading();
}
componentWillMount() {
LoaderActions.startPageLoading();
}
render() {
return (
<DocumentTitle title="component">
{ this.state.pageLoading && <Progress percent={this.state.pageLoading}/>}
<div id="content">
</div>
</DocumentTitle>
);
}
}
export default LinkAccounts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment