Skip to main contents

Making sense of the React's props model with Typescript

The key to making your components reusable in react is the react props model. This post will teach you how to manage the many prop uses in your component and create scalable React apps.

Introduction

Let's start by defining props and their primary function in order to understand the React Props paradigm.

Properties, often known as "props" in React, are an essential component of improving the reusability of React components.

In a nutshell, props are used in React apps to facilitate communication between components. A very important characteristic of any framework based on component-driven architecture is component communication. Most well-known frameworks, like Angular and Vue.js, offer unique methods for how components transfer data to one another.

Every single UI unit in a component-driven system is built up of components. Now that each of these parts would need to share data among themselves, you can see why frameworks must have this. For instance, we have the components shown below.

Root Parent Conponent
Child ComponentChild ComponentChild Component

According to the diagram above, state is transferred from the parent component to the child components by use of props, enabling the child components to access and modify that state.

The React Props Model

Consider props to be functions' arguments. JS functions are collections of programs that carry out specific tasks. A function that returns the sum of 1 and 2 is possible:

Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro nobis consectetur debitis? In animi nobis soluta at esse et nihil.

Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro nobis consectetur debitis? In animi nobis soluta at esse et nihil, non aut dolorem, deserunt odio quasi sunt veritatis, nisi quam?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro nobis consectetur debitis? In animi nobis soluta at esse et nihil, non aut dolorem, deserunt odio quasi sunt veritatis, nisi quam?