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 in a web browser, the result will be a?

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

社区洞察

其他会员也浏览了