Last active
August 29, 2015 14:19
-
-
Save suisho/bb028a8166fce91612a9 to your computer and use it in GitHub Desktop.
React0.13における各flux軍団の対応考察メモ ref: http://qiita.com/inuscript/items/9962ef2edbe1d0158fa2
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
class Container extends React.Component{ | |
render(){ | |
//一個storeとつなぐ親コンポーネントがラップする | |
return ( | |
<FluxComponent flux={this.flux} connectToStores={{ | |
messages: store => ({ | |
foo: store.getFoo(), | |
baz: store.getBaz() | |
}) | |
}}> | |
<InnderCompoent /> | |
</FluxComponent> | |
) | |
} | |
} | |
class InnderCompoent extends React.Component{ | |
render(){ | |
// 取り出したstoreはpropとして子に伝播 | |
const { foo, baz } = this.props | |
return ( | |
<div> | |
</div> | |
) | |
} | |
} |
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
class User extends React.Component { | |
render() { | |
return <div className="User">{this.props.user}</div>; | |
} | |
} | |
// createContainerで今までと似たような記法をする | |
module.exports = Marty.createContainer(User, { | |
listenTo: UserStore, | |
fetch: { | |
user() { | |
return UserStore.for(this).getUser(this.props.id); | |
} | |
}, | |
failed(errors) { | |
return <div className="User User-failedToLoad">{errors}</div>; | |
}, | |
pending() { | |
return this.done({ | |
user: {} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment