Professional Documents
Culture Documents
Introduction To React Design Patterns - Drupalcon Nashville - Amazee Labs
Introduction To React Design Patterns - Drupalcon Nashville - Amazee Labs
Brandon Williams
Amazee Labs
Before We Begin
React Design Patterns
Presentational Container
Presentational Container
const Commentlist = comments => ( class CommentListContainer extends
React.Component {
<ul>
componentDidMount() {
{comments.map( loadComments("/my-comments.json")
({ body, author }) => }
<li>{body}-{author}</li>
render() {
)}
return <CommentList
</ul> comments={this.state.comments}
) />;
}
}
Presentational/Container Components
Why? Difficulty
Separation of concerns
Reusable
Testable
Style guides
Stateless Components + Functional Programming
Why? Difficulty
Why? Difficulty
return this.props.render();
}
<HideLoading
loading{true}
render={() => (
<SubmitButton label="submit" />
)}
/>
Flux
Pattern for managing data Difficulty
All state flows in one direction
All state managed in the store
State changes cause re-renders
Redux
CFP Open! 2018.texascamp.org
Join us for
contribution sprints
Friday, April 13, 2018
#drupalsprint
Questions?
Brandon Williams
@rocketeerbkw