All I Know About REACT JS…
Today I will share my working experience with REACT JS. So, let’s get started.
React is a JavaScript library that is used for making web and mobile UI. It was developed by Facebook. In React, everything is a component that is responsible for some functionality. We can write small, small components & at the end, we can combine those small components together & make a big component.
Now, what is a component? How to define a component?
A component is nothing but a function (talking about functional component) which returns JSX.
what is JSX?
JSX stands for JavaScript XML. It allows us to write function calls in an HTML-like syntax. Our Browser doesn’t understand JSX. So in that case, we have to transpile it to JavaScript using JSX transformers (say babel) so that the browser can understand.
If all React components are a function, can we pass arguments?
Here comes the react magic. YESSSSS, we can pass arguments but we call them “Props”, which is a shorthand of properties. It can be used to pass data to different components. But it will only work in a uni-directional way, it means data will flow only from parent component to child component. Props are immutable. We can’t change it.
If props are immutable, then how we will change the data?
Here comes the react another magic. How we will change the data? “State” is the answer. State is something that holds/store the data. If we want to change the data value, then we need to store it in the state.