100daysofcode - Day56
Hello folks , the 56th/100 is reaching its end. And after a long dive in the UI / UX process, it’s the time for a new start with a new aim. Learning React JS, an open-source front-end JavaScript library for building user interfaces based on UI components.
Today we will begin with a gentle tour in this amazing library. So we can set the foundation base for the whole journey.
What is React JS ?
- React JS is a JavaScript library used to build single page applications.
- React JS is based on the components concept.
- It allows developers to write reusable UI components.
How can we create a React app ?
- We use the npx create-react-app command followed by the app name.
What is a React component ?
Independent and reusable pieces of code. They work in the same way as a normal JS function and they return HTML code.
Types of React components:
-
Functional components:
- JS functions that contain code that does not require any dependency from any other component
Example :
function Greetings() {
return <h1> Hello World </h1>
}
-
Class Components:
- Work in a similar way as function components, but they care about the passed data, where we can pass this data from one class to the other one.
- The render() method is the one that parse and display the specified HTML content to the screen.
Example :
class Greetings extends React.Component {
render() {
return <h1> Hello World </h1>
}
}