1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Fix autobinding bug, considering the components creation

This commit is contained in:
Tim Daubenschütz 2015-05-19 11:23:49 +02:00
parent 4da72d8846
commit fe5820b44a
2 changed files with 9 additions and 40 deletions

View File

@ -17,6 +17,13 @@ npm install
npm run watch
```
Code Conventions
============
For this project, we're using:
* 4 Spaces
* We use ES6
* We don't use ES6's class declaration because it does not support Mixins as well as Autobinding ([Blog post about it](http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding))
Reading list

View File

@ -3,42 +3,6 @@ import ArtworkListStore from '../stores/artwork_list_store';
import ArtworkListActions from '../actions/artwork_list_actions';
/*
class ArtworkList extends React.Component {
constructor(props) {
super(props);
this.state = ArtworkListStore.getState();
}
componentDidMount() {
ArtworkListStore.listen(this.onChange);
ArtworkListActions.fetchArtworkList();
}
componentWillUnmount() {
ArtworkListStore.unlisten(this.onChange);
}
onChange(state) {
console.log(this);
this.setState(state);
}
render() {
console.log('render');
return (
<ul>
{this.state.artworkList.map((artwork) => {
return (
<li>{artwork.title}</li>
);
})}
</ul>
);
}
};
*/
var ArtworkList = React.createClass({
getInitialState() {
return ArtworkListStore.getState();
@ -54,17 +18,15 @@ var ArtworkList = React.createClass({
},
onChange(state) {
console.log(this);
this.setState(state);
},
render() {
console.log('render');
return (
<ul>
{this.state.artworkList.map((artwork) => {
{this.state.artworkList.map((artwork, i) => {
return (
<li>{artwork.title}</li>
<li key={i}>{artwork.title}</li>
);
})}
</ul>