WHAT IS REACT.JS

WHAT IS REACT.JS

React?(also known as?React.js?or?ReactJS) is a?free and open-source?front-end?JavaScript library[3][4]?for building?user interfaces?based on?components. It is maintained by?Meta?(formerly Facebook) and a community of individual developers and companies.[5][6][7]

React can be used to develop?single-page, mobile, or?server-rendered?applications with frameworks like?Next.js. Because React is only concerned with the user interface and rendering components to the?DOM, React applications often rely on?libraries?for routing and other client-side functionality.[8][9]

Basic usage[edit]

The following is a rudimentary example of using React for the web, written in?JSX?and JavaScript.

import React from 'react';
import ReactDOM from 'react-dom/client';

/** A pure component that displays a message */
const Greeting = () => {
  return (
    <div className="hello-world">
      <h1>Hello, world!</h1>
    </div>
  );
};

/** The main app component */
const App = () => {
  return <Greeting />;
};

/** React is rendered to a root element in the HTML page */
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);        

based on the?HTML?document below.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>React App</title>
</head>
<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
</body>
</html>        

The?Greeting?function is a React component that displays the famous introductory?''Hello, world".

When displayed on a?web browser, the result will be a rendering of:

<div class="hello-world">
  <h1>Hello, world!</h1>
</div>        

Notable features[edit]

Declarative[edit]

React adheres to the?declarative programming?paradigm.[10]: 76 ?Developers design views for each state of an application, and React updates and renders components when data changes. This is in contrast with?imperative programming.[11]

Components[edit]

React code is made of entities called?components.[10]: 10–12 ?These components are modular and reusable.[10]: 70 ?React applications typically consist of many layers of components. The components are rendered to a root element in the?DOM?using the React DOM library. When rendering a component, values are passed between components through?props?(short for "properties").?Values internal to a component are called its?state.[12]

The two primary ways of declaring components in React are through function components and class components.[10]:

要查看或添加评论,请登录

Ashish Ranjan的更多文章

  • WHAT IS AGILE

    WHAT IS AGILE

    In software development, agile practices (sometimes written "Agile")[1] include requirements discovery and solutions…

  • WHAT IS GCP

    WHAT IS GCP

    Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs on the same…

  • WHAT IS AGILE

    WHAT IS AGILE

    In software development, agile practices (sometimes written "Agile")[1] include requirements discovery and solutions…

  • WHAT IS UNITY 3D

    WHAT IS UNITY 3D

    Unity is a cross-platform game engine developed by Unity Technologies, first announced and released in June 2005 at…

  • WHAT IS SHELL SCRIPTING

    WHAT IS SHELL SCRIPTING

    A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter.[1] The various…

  • WHAT IS API

    WHAT IS API

    An application programming interface (API) is a way for two or more computer programs to communicate with each other…

  • WHAT IS JAVA DEVELOPER

    WHAT IS JAVA DEVELOPER

    Despite its age and legacy, Java remains one of the most popular programming languages to this day. According to a 2021…

  • WHAT IS POWER BI

    WHAT IS POWER BI

    Microsoft Power BI is an interactive data visualization software product developed by Microsoft with a primary focus on…

  • WHAT IS PMO

    WHAT IS PMO

    A project management office (abbreviated to PMO) is a group or department within a business, government agency, or…

  • WHAT IS NETWORKING

    WHAT IS NETWORKING

    A computer network is a set of computers sharing resources located on or provided by network nodes. Computers use…

社区洞察

其他会员也浏览了