-
Break The UI Into A Component Hierarchy The first thing you’ll want to do is to draw boxes around every component (and subcomponent) in the mock and give them all names. If you’re working with a designer, they may have already done this, so go talk to them! Their Photoshop layer names may end up being the names of your React components! But how do you know what should be its own component? Use single responsibility principle , a component should ideally only do one thing. If it ends up growing, it should be decomposed into smaller subcomponents.
-
Thinking in React React is, in our opinion, the premier way to build big, fast Web apps with JavaScript. It has scaled very well for Facebook and Instagram. One of the many great parts of React is how it makes you think about apps as you build them. In this document, we’ll walk you through the thought process of building a searchable product data table using React.
-
Identify The Minimal (but complete) Representation Of UI To make your UI interactive, you need to be able to trigger changes to your underlying data model. React achieves this with state . The key here is DRY: Don’t Repeat Yourself . Figure out the absolute minimal representation of the state your application needs and compute everything else you need on-demand. For example, if you’re building a TODO list, keep an array of the TODO items around; don’t keep a separate state variable for the count. Instead, when you want to render the TODO count, take the length of the TODO items array.
-
Identify Where Your State Should Live. See the Pen Thinking In React: Step 4 on CodePen . OK, so we’ve identified what the minimal set of app state is. Next, we need to identify which component mutates, or owns , this state. Remember: React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state.
The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or function in a computer program should have responsibility over a single part of that program's functionality, and it should encapsulate that part.
What is a Static App? Static applications and websites render in the user's browser without the need for server side processing, this means that all the rendering of HTML, CSS, and JavaScript is done on the client side, rather then relying on server side technologies
i need to deploy it.
-
Is it passed in from a parent via props? If so, it probably isn’t state.
-
Does it remain unchanged over time? If so, it probably isn’t state.
-
Can you compute it based on any other state or props in your component? If so, it isn’t state.