What are components in React and how to create a component in React.
So we have already learned that a component is the basic building block of a React application and React is based on component based architecture.
Any React application you create can be built out of small React components.
Components can be nested inside one another.
To understand what a component is, let’s take a look at google’s homepage.
On the entire webapge, there are multiple elements.
The top navbar is one component.
Search bar is another component.
The search icon and the mic button are their own components.
Button is another component.
All these components combine together to form the entire UI.
Know you know what components look like on the UI, let’s now learn how they look like in terms of code.
When you want to create component, we create that in a JSX file.
Let’s now create our first component.
To create components, create a new directory in src folder called components.
Let’s place all our components in there.
No hard and fast rule, you can create components anywhere.
Create a new component called Hello.jsx
Make sure you always name your component in capitals.
Let’s create the simplest form of component.
A component in JS is nothing but a function.
A function in programming language is nothing but a blackbox which accepts some data in form or arguments and returns the processed data.
Component in react is something similar, they are just functions but instead of returning data, they return JSX.
So to create a component, we use regular JS syntax, you can use ES6 syntax as well if you want to.
Entire React Playlist: • React For Beginners 1 : Introduction ...
Auf dieser Seite können Sie das Online-Video React For Beginners 5 : Creating A Component In React mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Code Stoic 21 August 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 38,391 Mal angesehen und es wurde von 582 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!