American online social media and social networking service.
React is a popular JavaScript library for building user interfaces, particularly for single-page applications. It's used for handling the view layer in web and mobile apps. React allows you to design simple views for each state in your application, and it will efficiently update and render the right components when your data changes.
React was first created by Jordan Walke, a software engineer at Facebook, and it was first deployed on Facebook's newsfeed in 2011 and on Instagram in 2012. It was then open-sourced at JSConf US in May 2013.
React allows developers to create large web applications that can change data, without reloading the page. The main purpose of React is to be fast, scalable, and simple. It works only on user interfaces in the application, which makes it easy to be integrated with other libraries or existing projects.
In React, everything is a component. Components are the building blocks of any React application, and a single app usually consists of multiple components. A component is essentially a piece of the user interface. It splits the UI into independent, reusable pieces that can be processed separately.
JSX, or JavaScript XML, is an extension for JavaScript that allows you to write HTML in React. It makes it easier to write and add HTML in React.
State and props are both plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. Props get passed to the component similar to function parameters, whereas state is managed within the component similar to variables declared within a function.
Building a simple application with React involves creating components, defining their state and props, and specifying the UI they render. You can start by creating a new React app using Create React App, a comfortable environment for learning React, and a convenient way to start a new single-page application.
React Hooks are a new addition in React 16.8 that let you use state and other React features without writing a class. Hooks are functions that let you “hook into” React state and lifecycle features from function components. They do not work inside classes — they let you use React without classes.
By the end of this unit, you should have a basic understanding of React and be able to start building a simple React application. You should also understand the concepts of components, JSX, state, props, and React Hooks.