Skip to content

Instantly share code, notes, and snippets.

@jsonnull
Forked from markerikson/render-logic.js
Created August 30, 2016 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsonnull/6a602ef094dd135f2dd690d1fe0b38d1 to your computer and use it in GitHub Desktop.
Save jsonnull/6a602ef094dd135f2dd690d1fe0b38d1 to your computer and use it in GitHub Desktop.
React render function organization
class ParentComponent extends Component {
render() {
const {a, b, someBoolean, someList} = this.props;
const conditionalComponent = someBoolean ? <SomeComponent /> : null;
const listItems = someList.map(item => <ListItem item={item} />);
return (
<div>
<div>A: {a}, B: {b}</div>
{conditionalComponent}
{listItems}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment