Skip to content

Instantly share code, notes, and snippets.

@norayr93
Forked from cdiggins/react-best-practices.md
Created February 10, 2019 07:57
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 norayr93/a5ab5abe17b55b63b3446159419051d1 to your computer and use it in GitHub Desktop.
Save norayr93/a5ab5abe17b55b63b3446159419051d1 to your computer and use it in GitHub Desktop.
React Best Practices

React Best practices

I have summarized and compiled a list of React.JS best practices from various sources across the internet.

From the React docs

Presentational and Container Components

Separate components into presentational or container components

  • Presentation components

    • concerned with how things look
    • allow containment via this.props.children
    • often have styles
    • have no dependencies on rest of approach
    • don't specify how data is loaded or mutated
    • Receive data and callbacks exclusively via props.
    • Rarely have their own state (when they do, it’s UI state rather than data).
  • Container components

    • concerned with how things work
    • usually don’t have any DOM markup of their own except for maybe some wrapping divs
    • provide data and behavior to presentational or other container components.
    • are often stateful
  • Because functional components are easier to understand, use them unless you need state, lifecycle hooks, or performance optimizations

Best Practices From Other Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment