React for beginners- Md Iqbal Hossain
Nowadays react is one of the most popular libraries for making web applications. Let's see the basics of this library in an easy way.
You have noticed that I mentioned react as a library, not a framework. Because you cannot find a complete solution of making web app by using only react. You need many more things to implement a complete web application.
React is component based
Like other programming languages react has a component feature that is like a function. We can call the function as needed. Even can reuse as per necessity.
Create a component using ES6
Introducing JSX
Look at the tag syntax. It is neither a string nor HTML. This is called JSX. it is a syntax extension to JavaScript.
Props and Components
The full meaning of props is properties. In react app Components can refer to other components in their output and the properties of one component can be sent to another component by using props.
Event Handling
In react events can be handled in some ways. One of the best ways is to binding calls and using the arrow function.
Conditional Rendering
Conditional rendering is really an amazing thing. Let's explore it with some examples. Consider these two components
We’ll create a Greeting component that displays either of these components depending on whether a user is logged in: