We believe that React is the foremost tool for building fast, big web applications. Our Facebook and Instagram pages have benefited greatly from it.
When building an app with React, you have to think of the app as a whole. We will cover the steps involved in building a searchable product data table using React in this document.
Start With A Mock
Assume we already have a JSON API and a mock from our designer. An example of a mockup is this:
Mockup
Our JSON API returns the following data:
[
{category: “School Goods”, price: “$59.99”, stocked: true, name: “Books”},
{category: “School Goods”, price: “$11.99”, stocked: true, name: “Notebook”},
{category: “School Goods”, price: “$30.99”, stocked: false, name: “Uniform”},
{category: “Gadgets”, price: “$100.99”, stocked: true, name: “Airpods”},
{category: “Gadgets”, price: “$300.99”, stocked: false, name: “iPhone 12 Pro”},
{category: “Gadgets”, price: “$200.99”, stocked: true, name: “iPhone X”}
];
Step 1: Structuring The UI Through Component Hierarchies
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 the same techniques for deciding if you should create a new function or object. One such technique is the single responsibility principle, that is, a component should ideally only do one thing. If it ends up growing, it should be decomposed into smaller subcomponents.
Since you’re often displaying a JSON data model to a user, you’ll find that if your model was built correctly, your UI (and therefore your component structure) will map nicely. That’s because UI and data models tend to adhere to the same information architecture. Separate your UI into components, where each component matches one piece of your data model.
Component diagram
Our app has five components, as you can see here. Each component’s data has been italicized.
FilterableProductTable (orange): contains the entirety of the example
SearchBar (blue): receives all user input
ProductTable (green): displays and filters the data collection based on user input
ProductCategoryRow (turquoise): displays a heading for each category
ProductRow (red): displays a row for each product
If you look at ProductTable, you’ll see that the table header (containing the “Name” and “Price” labels) isn’t its own component. This is a matter of preference, and there’s an argument to be made either way. For this example, we left it as part of ProductTable because it is part of rendering the data collection which is Product Tables responsibility. However, if this header grows to be complex (e.g., if we were to add affordances for sorting), it would certainly make sense to make this its own ProductTableHeader component.
Now that we’ve identified the components in our mock, let’s arrange them into a hierarchy. Components that appear within another component in the mock should appear as a child in the hierarchy:
FilterableProductTable
SearchBar
ProductTable
ProductCategoryRow
ProductRow
Step 2: Create a static variant in React
Your component hierarchy is now ready for implementation. To build a version that renders your data model but does not have interactivity, you can build a version that takes your data model and renders the UI. Adding interactivity requires a lot of thinking while creating a static version requires a lot of typing. Let’s find out why.
You will want to create components that reuse other components and pass data via props to build a static app that renders your data model. Props are a means of passing data between children and parents. You shouldn’t use the state to build this static version if you’re familiar with the concept of state. Data that changes over time is considered state and is reserved for interactive data. You do not need this version of the app since it is static.
It is possible to build top-down or bottom-up. You can either start with the components higher in the hierarchical structure (such as FilterableProductTable, for instance) or lower in the hierarchy (ProductRow). If your project is simpler, you can go top-down; if it is more complex, you will need to build bottom-up and test as you go.
Your data model will be rendered using reusable components after this step. As this is a static version of the app, all of the components will have render() methods. Data models are props for the topmost component (FilterableProductTable). In this situation, the UI will be updated if you call ReactDOM.render() again after changing your underlying data model. This enables you to see where to make changes to your UI. One-way data flow (also known as one-way binding) keeps everything modular and fast in React.
Putting Props vs. State into Context
React has two types of “model” data: props and state. As part of React, props are variables that are passed to the component from its parent component. The state, on the other hand, is a variable, but it is directly initialized and managed by the component. Initializing the state can be done via props.
Step 3: Find a minimal (but complete) representation of UI state
It’s crucial that you can trigger changes to your underlying data model so that your UI can be interactive. The state allows React to achieve this.
First, you need to figure out what minimal set of mutable state your app requires. In this case, the key is DRY: Don’t Repeat Yourself. Calculate everything else you need based on the state your application needs, and then find the minimum representation of that state you need. As an example, if you’re building a task list, you should keep an array of all the items; do not store a separate variable for the number of items. You should instead take the length of the task items array when rendering the task count.
Just imagine all the information that our example application has to offer. What we have is:
A list of the original products
User-inputted search text
Checkbox value
Products sorted by the filter
As we go through each, let’s identify which is the state. Consider the following three questions for each piece of data:
Are props passed in from a parent? Then it is probably not a state.
Is it unchanged over time? Then it is probably not a state.
Is it possible to compute it based on any other state or prop in your component? Therefore, it does not fall under the state umbrella.
Originally, a list of products is passed in as a prop, so that is not a state. There are no algorithms that can compute the search text and the checkbox as they change over time. Last but not least, the filtered list of products doesn’t constitute a state because it is simply the result of combining the original list of products with the search text and value of the checkbox.
So finally, our state is:
The search text the user has entered
The value of the checkbox

Step 4: Decide where your state should reside
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.
React is all about one-way data flow down the hierarchy of components. Identifying which component owns which state may not be obvious at first. The most challenging part of this is often figuring this out, so know these steps:
As you develop your application, keep the following state in mind:
Determine which components render something based on that state.
In your hierarchy, find the component with the most common owner (the component one component above the others).
Ownership of the state should either be assigned to the common owner or to another higher component.
When a component doesn’t make sense to own the state, you can create a new component that holds the state exclusively and add it somewhere in the hierarchy above the common owner component.
The following strategy will help us with our application:
ProductsTable should filter product lists according to their states and SearchBar should display the search text and the checked status.
FilterableProductTable is the common component owner.
The filter text and checked value should reside in FilterableProductTable conceptually.
We have decided to put state within our FilterableProductTable. Add the following property to the instance: this.state = {filterText: ”, inStockOnly: false} in the constructor of FilterableProductTable to reflect the initial state of the application. After that, pass filterText and inStockOnly as parameters to ProductTable and SearchBar. Additionally, set the values of the form fields in SearchBar using the props for ProductTable and SearchBar.
Setting filterText to “ball” will give you a preview of how your application will behave. Upon opening the data table, you will see that the update has been made correctly.
Step 5: Create a reverse data flow
Currently, we have built a renderer that works when props and state flow down the hierarchy. Likewise, data must flow the other way: deep in the hierarchy, the form components have to know how to update the FilterableProductTable.
Data flow in React is explicit to help you understand how your program works, but it does require a bit more typing than traditional two-way data binding.
You will see that React ignores your input if you attempt to type or check the box in the current version of the example. Keeping the value prop of the input constant, we have set the value prop to reflect the state passed in from FilterableProductTable.
Here are a few things we should consider. Our goal is to update the form state every time the user makes a change. In order to ensure that each component updates its own state independently, FilterableProductTable passed callbacks to SearchBar that fire whenever the state change occurred. By using the onChange event on the inputs, we can be notified of the change. Upon receiving calls from FilterableProductTable, the app will update its state using setState().
This concludes the idea
This should give you an idea of how to think about building components and applications with React. This may seem like an extra step, but remember that code is read much more than it’s written, and it’s easier to read this modular, explicit code. With this explicitness and modularity developing within your components library, your lines of code will get smaller and smaller as you start to develop large libraries of components.

50 responses to “The React way of thinking”
[8167]Cow88 Casino: The Premier Online Casino Philippines for the Best Online Slots and Seamless GCash Casino PH Access. Cow88 Casino is the premier Online Casino Philippines, offering the Best Online Slots Philippines and seamless GCash Casino PH access. Secure your Cow88 Login today! visit: cow88
[3011]1plusgame: Top Slot Online in the Philippines. Easy Login, Register, and Download App via Official Link. Experience 1plusgame, the top slot online in the Philippines. Use our official link for fast 1plusgame login, easy register, and 1plusgame download app. Join and win now! visit: 1plusgame
[400]eejl Official Casino Philippines: Experience top eejl slot games with fast eejl login, easy register, and seamless eejl app download. Join eejl Official Casino Philippines for top eejl slot games. Experience fast eejl login, easy eejl register, and a seamless eejl app download. Play and win today! visit: eejl
[3843]Experience the Best Online Casino in the Philippines at Nustar Casino Cebu visit: nustaronline
[861]Inplaycasino Online Casino Philippines: Fast Inplaycasino Login, Easy Register, and Official App Download for the Best Inplaycasino Slots Experience. Join Inplaycasino Online Casino Philippines! Experience fast inplaycasino login, easy inplaycasino register, and official app download for the best inplaycasino slots. visit: inplaycasino
[9057]135phpgames: Best Online Casino & Slot in the Philippines. Quick Login, Easy Register, and Official App Download for Big Wins. Join 135phpgames, the premier online casino in the Philippines. Easy 135phpgames login & register for top 135phpgames slot action. Get the 135phpgames download app for big wins today! visit: 135phpgames
[9976]Taya3653 Online Casino: Top Philippines Gaming Platform. Quick Login, Easy Register, and App Download for Premium Slot Games. Experience the best at Taya3653 Online Casino, the top Philippines gaming platform. Fast taya3653 login, easy register, and premium taya3653 slot games await you. Secure your taya3653 app download today for the ultimate mobile casino experience and big wins! visit: taya3653
[8559]no1jili: The Top Philippines Casino & Slot Hub. Easy no1jili login, fast register, and official app download for the ultimate gaming experience. Join no1jili, the premier Philippines casino & slot hub. Experience easy no1jili login, fast register, and official no1jili app download for top gaming today! visit: no1jili
[7628]RG777 Online Casino: The Best Slot Gaming in the Philippines. Register or Login to enjoy top-tier RG777 Slots and get the official RG777 App Download for non-stop winning action. Experience the best gaming at RG777 Online Casino. Complete your RG777 register or RG777 login to play top RG777 slot games. Get the official RG777 app download for non-stop winning action in the Philippines! visit: rg777
[7596]PHPVIP Official Link: Login, Register, & Download the Best Philippines Slots App Access the PHPVIP official link for the best Philippines slots app. Secure your phpvip login, complete your phpvip register, and get the phpvip download to enjoy premium casino games and big wins today! visit: phpvip
[1486]911jl Casino: The Best Online Casino Philippines with GCash. Secure Login & Fast App Download for Top Gaming. Experience the best online casino Philippines at 911jl casino. Secure your 911jl login today for premium gaming and seamless transactions with the top GCash online casino PH. Start winning now and get the 911jl app download for fast, secure access to your favorite games anytime, anywhere. visit: 911jl
[6475]23phwin login|23phwin casino|23phwin register|23phwin download|23phwin slots Experience **23phwin casino**, the Philippines’ premier online gaming hub. Complete your **23phwin register** today to enjoy top-tier **23phwin slots**, easy **23phwin login** access, and a fast **23phwin download** for non-stop mobile action! visit: 23phwin
[3630]56jilicasino: The Top Philippines Online Casino – Register & Login for Premium Slot Games and Fast App Download Experience 56jilicasino, the top Philippines online casino. 56jilicasino register now for premium slot games. 56jilicasino login or use the app download for fast wins! visit: 56jilicasino
[5279]Tongits Online Real Money: Easy Login, Register & App Download for the Best Casino Slots in the Philippines. Experience Tongits online real money! Enjoy easy Tongits login, fast Tongits register, and the Tongits app download for the best casino slots in the Philippines. Play and win big today! visit: tongits
[277]EnergyCasino Philippines: Fast Login, Register & App Download. Play Top Slots with Exclusive Promo Codes today! Experience the best of EnergyCasino Philippines! Enjoy fast EnergyCasino login, quick register, and the official EnergyCasino app download. Play top-rated EnergyCasino slots and claim your exclusive EnergyCasino promo code to start winning today. Join the ultimate PH gaming destination now! visit: EnergyCasino
[7042]MerryPH Online Casino Philippines: Easy Login, Register, Slot Games, and Official App Download. Experience the ultimate gaming thrill at MerryPH, the most trusted online casino in the Philippines. Enjoy a seamless MerryPH login and quick MerryPH register process to access world-class MerryPH slots and live dealer games. Enhance your mobile experience with the official MerryPH app download. Join MerryPH online casino today for secure betting, exciting bonuses, and big wins! visit: merryph
[3576]FB7775: Best Philippines Online Casino. Quick FB7775 Login, Register & App Download for Top Slot Games and Casino Login. Join FB7775, the best Philippines online casino! Experience quick fb7775 login, easy fb7775 register, and fb7775 app download for top fb7775 slot games and casino login. visit: fb7775
[4343]Casinova Official Site: Best Online Slots in the Philippines. Quick Login, Register & App Download. Play at the Casinova official site for the best Casinova online slots in the Philippines. Quick Casinova login, register, and Casinova app download. Start winning today! visit: Casinova
[2920]Maxwinph: Best Casino Online in the Philippines. Login, Register, or Download the App to Play Exciting Slot Games Today. Join Maxwinph, the best casino online in the Philippines. Maxwinph register or login now to play exciting slot games. Get the maxwinph app download and win today! visit: maxwinph
[1951]matejl Casino Philippines: Top Online Slots, Easy Login & Registration. Download matejl Today for the Ultimate Casino Experience! Experience matejl Casino Philippines! Enjoy easy matejl login & register for top matejl slot games. Start your matejl download today for the ultimate casino action. visit: matejl
[7877]okgames Philippines: Top Online Casino & Slots – Easy Login, Register, and App Download Experience okgames Philippines, the top online casino for premium okgames slot games. Enjoy a seamless okgames login and okgames register process to start winning. Get the fast okgames app download for the best mobile gaming experience in the Philippines today! visit: okgames
[977]Ebingoplus Casino Philippines: Best Online Slots, Easy Login & Register. Download the Ebingoplus App for the Ultimate Gaming Experience! Experience Ebingoplus Casino Philippines! Play top ebingoplus slots with fast login & register. Get the ebingoplus app download for ultimate gaming. Join today! visit: ebingoplus
[6613]PH357: Best Online Casino & Slots in the Philippines. Quick PH357 Login, Register, and App Download to Win Big Today! Join PH357, the Philippines’ top online casino. Secure PH357 casino login, fast ph357 register & ph357 app download. Play ph357 slot games and win big today! visit: ph357
[9134]Phjili Online Casino Philippines: Secure Phjili Login, Register & App Download. Play the Best Phjili Slots and Casino Games Online! Experience the top Phjili online casino in the Philippines! Secure Phjili login and Phjili register. Get the Phjili app download for premium Phjili slots and big wins. Play now! visit: phjili
[2693]jl333 Online Casino Philippines: Best Slots, Easy Login, Register & App Download Join JL333 Online Casino Philippines for the best JL333 slot games. Quick JL333 login, easy JL333 register, and secure JL333 download for mobile play. Sign up today! visit: jl333
[2445]Acejili Casino: Best Online Slots in Philippines. Register, Login & App Download Today! Experience Acejili Casino, the top choice for online slots in the Philippines! Enjoy fast acejili login, easy acejili register, and seamless acejili app download. Play the best acejili slots and win big today! visit: acejili
[6490]jl365 Online Casino Philippines: Quick jl365 Login, Register, and App Download for the Best jl365 Slot Games. Experience the top jl365 online casino Philippines! Fast jl365 login, easy jl365 register & jl365 app download. Play the best jl365 slot games & win big today! visit: jl365
[9870]PH666: The Best Online Casino Philippines – Legit Slots & Easy GCash Payouts Experience the ultimate gaming at **PH666 online casino**, the **best online casino Philippines**. Secure your **PH666 legit login** today to enjoy premium **PH666 slot games** and fast, easy withdrawals. Join the most trusted **GCash casino Philippines** for a seamless, legit, and rewarding casino experience. visit: ph666
[1894]PG777: The Best Legit Online Casino Philippines – Play Real Money Slot Games with Easy GCash Payouts. Experience PG777, the best legit online casino Philippines. Play real money slot games with fast GCash payouts. Secure your PG777 slot games login today and win big at the most trusted real money casino in the PH! visit: pg777
[2531]Winph777 Online Casino Philippines: Secure Login, Easy Register, and App Download for Top Slot Games. Experience Winph777 online casino Philippines! Enjoy secure winph777 login, fast winph777 register, and top winph777 slot games. Get the winph777 app download now for elite gaming. visit: winph777
[753]WineHQ Online Casino: The Best Legit Real Money Casino in the Philippines. Experience top-tier gaming at WineHQ Online Casino, recognized as the best legit real money casino in the Philippines. Fast-track your winnings with a secure WineHQ login or enjoy seamless play via the WineHQ Casino app download. Join the most trusted online casino Philippines has to offer and start winning real cash today! visit: winehq
[5252]Winph8 Online Casino Philippines: Secure Winph8 Login, Fast Register & App Download for Premium Slot Games. Join Winph8 Online Casino Philippines for premium Winph8 slot games. Enjoy a secure Winph8 login, fast Winph8 register, and easy Winph8 app download. Experience the ultimate gaming platform and start winning today! visit: winph8
[9676]500jl Casino Philippines: Official Login & Register – Play Top Slots & Download the 500jl App Now. Join 500jl Casino Philippines for top-tier gaming! Secure your 500jl login or 500jl register today to play premium 500jl slot games. Download the 500jl app and start winning now! visit: 500jl
[8052]PHBuwenas Online Casino: Register and Login for Top Slot Games & Official App Download in the Philippines. Join PHBuwenas Online Casino! Easy phbuwenas login & phbuwenas register for top phbuwenas slot games. Fast phbuwenas app download available for the best gaming in the Philippines. visit: phbuwenas
[2470]GalaxyBet: The Best Online Casino in the Philippines for GCash Gambling & Online Slots. Experience top-tier gaming at GalaxyBet, the best online casino in the Philippines. Enjoy seamless GCash online gambling PH and a massive variety of high-payout online slots Philippines. Secure your GalaxyBet PH login today to access exclusive bonuses and fast withdrawals at the most trusted GalaxyBet online casino Philippines. visit: galaxybet
[1928]Letswin Online Casino Philippines: Quick Letswin Login & Register. Play Top Letswin Slots & Secure your Letswin App Download for the Ultimate Gaming Experience. Experience Letswin Online Casino Philippines! Quick Letswin login & register to play top Letswin slots. Secure your Letswin app download for the best gaming now. visit: letswin
[127]18jl Online Casino Philippines: Easy Login, Register & App Download for Top 18jl Slots. Join 18jl Online Casino Philippines! Quick 18jl login & 18jl register to play premium 18jl slot games. Get the 18jl app download for mobile fun. Win big today! visit: 18jl
[2517]90jili Online Casino Philippines: Secure Login, Easy Register, & App Download for the Best Slot Games. Experience the ultimate gaming at 90jili Online Casino Philippines! Enjoy a secure 90jili login, easy 90jili register, and fast 90jili app download to play the best 90jili slot games. Join now for top rewards and a premium casino experience in the Philippines. visit: 90jili
[5973]Dailyjili Casino Philippines: Best Online Slots, Quick Dailyjili Login & Register. Get the Dailyjili App Download for Premium Gaming Action. Join Dailyjili Casino Philippines! Experience fast dailyjili login & register for top dailyjili slot games. Get the dailyjili app download for premium gaming at dailyjili casino today. visit: dailyjili
[5298]Bet999 Philippines: Top Online Casino & Slots. Easy Login, Register, and App Download. Join Bet999 Philippines, the #1 online casino for premium gaming! Experience easy bet999 login, fast register, and seamless bet999 app download. Play the best bet999 slots and live dealer games to win big today. Start your ultimate bet999 online casino journey now! visit: bet999
[820]Dito777: The Most Trusted Legit Online Casino Philippines – Your Best GCash Casino for Big Wins! Dito777 is the most trusted legit online casino Philippines. Join the best GCash casino PH for big wins. Dito777 login now for online gambling Philippines! visit: dito777
[8616]Balato88: The Best Online Casino in the Philippines for GCash Slots and Instant Wins visit: balato88
[1897]Pinas77: The Best Online Casino in the Philippines. Login, Register, and Play Pinas77 Slot or Download the App Today! Experience Pinas77, the best online casino in the Philippines! Quick Pinas77 login and register to play top Pinas77 slot games. Download the Pinas77 app today! visit: pinas77
[1659]The Premier Online Casino and Best Online Slots in the Philippines visit: mwplay88fun
Casino Plus App Download? On it! Mobile gaming convenience is the best. Hopefully, they have good games! Download here: casino plus app download
Looking for the best dự đoán xsmn minh ngọc hôm nay. Where are you guys getting your tips? Need a leg up on the competition! dự đoán xsmn minh ngọc hôm nay
bongdaso12.info is my go-to site for checking football scores, give it a try. Find info at bongda so.
160bet, eh? Had a looksee. Seems legit. Nothing groundbreaking, but a solid option if you’re looking for somewhere new to place your bets. 160bet
678bet, I’ve heard about them. Simple to use. Might be your lucky number! Check it out yourself and give it a go. 678bet
Okay, 80gamesbet…tons of games to choose from! If you’re easily overwhelmed, might want to take it slow. But if you like variety, you’ll be in heaven. 80gamesbet