Created
September 24, 2015 10:47
-
-
Save suchitpuri/a4afbbc8aa07023d68b8 to your computer and use it in GitHub Desktop.
Component Talking to Store in React + Flux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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