React - Building Process

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > React

1 - About

The different steps to build something in React.

3 - Steps

3.1 - Design a Component Hierarchy

Design a Component Hierarchy

Draw boxes around every component (and subcomponent) in the mock and give them all names. The designer have for sure already done it and the Photoshop layer names may end up being the names of your React components.

Advertising

3.2 - Build a static version

Build a static version that takes your data model and renders the UI but has no interactivity.

It's best to decouple these processes because building a static version requires a lot of typing and no thinking, and adding interactivity requires a lot of thinking and not a lot of typing.

Don't use state at all to build this static version. State is reserved only for interactivity, that is, data that changes over time.

3.3 - Identify the minimal set of state

As state to trigger UI changes, you first need to think of the minimal set of mutable state that your app needs.

If the answer to the below question is yes, it probably isn't state.

  • Is it passed in from a parent via props?
  • Does it remain unchanged over time?
  • Can you compute it based on any other state or props in your component?

4 - Documentation / Reference

web/javascript/react/process.txt · Last modified: 2019/06/17 11:12 by gerardnico