Created
January 26, 2015 12:14
-
-
Save roman01la/39545dae9843017e1c8e to your computer and use it in GitHub Desktop.
How to avoid storing application data within controller-view.
This file contains hidden or 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
import React from 'react'; | |
import AppActions from './actions'; | |
import ItemsStore from './items-store'; | |
let List = React.createClass({ | |
componentDidMount() { | |
ItemsStore.addChangeListener(this.forceUpdate.bind(this)); | |
}, | |
componentWillUnmount() { | |
ItemsStore.removeChangeListener(this.forceUpdate.bind(this)); | |
}, | |
render() { | |
let list = ItemsStore.getState().items | |
.map((item, index) => <li key={index}>{item}</li>); | |
return ( | |
<ul>{list}</ul> | |
); | |
} | |
}); | |
React.render(<List />, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment