write first component in React!
The component is nothing but a function in React and it's just a piece of reusable code.
First, we will create a components folder inside the src folder and create a component there and also we will create an Item.css file for the Item component.
example -> Item. jsx
This Item.jsx file is nothing but a component and we created this inside the components folder. The naming convention of components must be Pascal Notation
for example:
FirstItem.jsx
HelloWorld.jsx
writing our first components:
As we can see in the above code we have written XML code but the thing is that we can understand easily XML code but the browser doesn't understand the XML code so
when we run the command npm start. It will convert so that browser can understand it. It's nothing but HTML code inside javascript code.
To use this component first we have to import the component. let's say we need to import the Item component inside the App component
when we execute this app, the output is shown below:
This is how we create and use components in React.