Skip to content

Instantly share code, notes, and snippets.

View otaviocorrea's full-sized avatar
🏠
Working from home

Otavio Corrêa otaviocorrea

🏠
Working from home
  • Porto Alegre, Rio Grande do Sul - Brasil
  • 07:38 (UTC -03:00)
  • LinkedIn in/ocps
View GitHub Profile
@otaviocorrea
otaviocorrea / render-logic.js
Created January 6, 2020 00:11 — forked from markerikson/render-logic.js
React render function organization
class ParentComponent extends Component {
render() {
// My basic render function structure:
// 1) Extract values from props and state
const {a, b, someBoolean, someList} = this.props;
// 2) Render any dependent items into temporary variables, such as conditional components or lists
const conditionalComponent = someBoolean ? <SomeComponent /> : null;
const listItems = someList.map(item => <ListItem item={item} />);