Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

React Tutorial

React Tutorial

React is a JAVASCRIPT library for building user interfaces.

React is mainly used for building UIs, and many people consider React to be the V (View) in MVC.

React originated from an internal project at Facebook, used to build Instagram's website, and was open-sourced in May 2013.

React has high performance and very simple code logic, and more and more people have begun to pay attention to and use it.


React Features


Knowledge you need before reading this tutorial:

Before starting to learn React, you need the following basic knowledge:


React First Example

In each chapter, you can edit examples online and then click a button to view the results.

This tutorial uses React version 18.2.0; you can visit the official website https://react.dev/ to download the latest version.

React example

<

div

id

=

"

example

"

div

<

script

type

=

"

text/babel

"

// Simple React component function App() { return

<

h1

Hello, React!

h1

; } const root = ReactDOM.createRoot(document.getElementById("example")); // render the React component to the DOM root.render(

<

App

/>

);

script

Try it »

** Importing External Scripts:**




These three lines of code import the React, ReactDOM, and Babel Standalone libraries respectively.

Or a React development environment created using the create-react-app tool (introduced in the next chapter):

Example

import

React from

"react"

;

import

ReactDOM from

"react-dom/client"

;

function

Hello

(

props

)

{

 

return

<

h1

Hello World

!

h1

;

}

const

root

=

ReactDOM.

createRoot

(

document.

getElementById

(

"root"

)

)

;

root.

render

(

<

Hello

/>

)

;

At this point, open the browser http://localhost:3000/ and it will output:

Hello World!

References