These 2 Questions you have to ask yourself when building React Apps

Michael Hammond
Nov 4 · 2 min read

The 2 questions are,

  1. Do I have to split this into multiple components?
  2. Do I have to keep all of this together as one big component?
ReactJs
ReactJs
Snipped from React Official Website

I have been using React for 12 months. I have also observed people use this library. I have done a lot of debugging and fixing of errors in several React Apps and these 2 questions always come out when fixing issues around how data flows through React Apps.

  1. Why did you decide to split this into multiple components?
  2. Why did you decide to keep all of this together as one big component?

So why should you ask yourself these 2 questions?

I personally do not like the idea of jumping straight to writing code to solve a problem without giving it enough thoughts. What you end up with is getting stuck in the middle of the problem and not knowing what to do. Like your vehicle breaking down after you have covered half of your journey and there’s no way for you to fix it.

React developers can write,

<p>{this.props.task.name}</p>

as some JSX to render in their app.

And they get an error in the console saying “Cannot read property name of undefined”.

What a nasty error this is.

For those who have taken a beaten from this error before, you know how this can take away most of your precious time.

The error talks about a developer who is expecting a task but got nothing. If you ask yourself these 2 to very important questions on whether you should keep components as one or split it apart then you are most likely to avoid this nasty error.

I want you to always ask yourself whether it is necessary to split up your components or build a single component React App.

Thank You
Michael Hammond

Written by

I hold a Bachelor Degree in Agricultural & Biosystems Engineering. I am currently an Entrepreneur in Training (EIT) at MEST Africa.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade