What’s the component of React.JS/react-native?

Mehmet Ali Yılgın
2 min readJan 25, 2022

When you develop a mobile application, u have to create components for screens. Okey, so what’s the component? Components are code snippets that allow you to write code once and use it in many places. It’s kinda functions.

A function in JavaScript. (EsmaScript6)

If you want to perform an operation in more than one way, you use a function for this. Functions can be created with or without parameters, depending on their types.

Components are not different from a functions. This investment is a subprogram. Just have a different return: Design. When you need to use any design code in more than one page in the mobile application, you create a component.

A Component Example (react-native)

You export “Header” for other screens. “styles” is for It is written in a separate place for the code to be readable. This Header.tsx takes parameters as you can see: props, drawer, centerText, leftElement, leftFunction, rightElement, logo, textStyle, theme_light, background.

In the example you see, you see a component that takes parameters like a function. Thanks to this component, the headings at the top of the pages are written once. It is then import from the relevant page when necessary.

If you want to increase the readability of your code, you have to use these components. As a matter of fact, React.JS, react-native provides these component structures to its developers. There are no performance issues either. By using component structures, you can easily overcome future maintenance problems. It is a system that is useful in every way. With “props” redirects, your work becomes much easier.

React.JS Introduction

--

--