React ??? ??? ????? ??? ?? ??? JavaScript ????????. 2013? Facebook?? ??? ? ??? ?? ?? ?? ????? ??? ?? ???? UI ??? ??? ??????. ??? ? ?? ??? ??? ???? ??? React? ???? ??? ??? ?? UI? ????? ??? ?? ? ????.
? ????? React? ?? ??? ?? ??? ?? ??? ?? ??? ???? ??? ????? ???? ?? ?? ??? ?????.
???? ??????
????? React? ?? ? ??? ??? ?????? ????? ??? JavaScript ????????. MVC(Model-View-Controller) ????? ??? ??????? ? ??? ??? ???. React? ???? ??????? ??? ??? ?? ????? ?????? ?????? ?? ?? ? ????.
React? ???? ??? ??????
- ??? ??? ?? ??: ??? UI? ????? ??? ??? ?? ??? ??? ?????.
- ?? DOM: ?? DOM? ?????? ?? ?? ?? DOM? ?? ??? ???? ? ??? ???????.
- ???: UI?? ?? ?? ??? ???? ???? React? ?????.
- ??? ???: Redux, React Router, Next.js? ?? ?????? ???? React? ??? ?????.
React? ???? ??
React ??????? React ?? ?? ??? ?? ??? ???? ?????. ?? ??? ??, ?? ? ???? ????? UI? ???? ?????.
??? ????
??? ?? ??? props? ???? ????? React ??? ???? ??? JavaScript ?????. ?? ?? React ???????? ?? ???? ??? ?? ?????.
?: ?? ?? ????
function Welcome(props) { return <h1>Hello, {props.name}!</h1>; } // Usage <Welcome name="Alice" />;
??? ????
??? ????? React.Component ???? ???? ES6 ??????. ??? ???? ??? ????? ???????.
?: ?? ??? ?? ??
function Welcome(props) { return <h1>Hello, {props.name}!</h1>; } // Usage <Welcome name="Alice" />;
???? ??
?: ??? ?? ??? ?? ??
import React, { Component } from 'react'; class Welcome extends Component { render() { return <h1>Hello, {this.props.name}!</h1>; } } // Usage <Welcome name="Alice" />;
??:
- ?? ??: useState ??? ?? ?? ?? ??(??)? ???? ? ?????.
- Props: Props? ?? ?? ??? ???? ??? ? ????.
- ???: onClick ??? ???? ??? ??? ? ??? ???????.
Prop vs State
Feature | Props | State |
---|---|---|
Definition | Data passed to a component from its parent. | Data managed within the component. |
Mutability | Immutable (cannot be changed by the receiving component). | Mutable (can be updated within the component). |
Usage | Used for passing data to child components. | Used for dynamic data that changes over time. |
???? ??
State? ?? ??? ????? ?? ???? ???? ? ???? React? ?? ?????. ??? ????? ?? ??? ?? useState ??? ?????.
?: ??? ??? ???
function Welcome(props) { return <h1>Hello, {props.name}!</h1>; } // Usage <Welcome name="Alice" />;
????? Prop
Prop? ?? ?? ???? ?? ?? ??? ???? ???, ???? ?? ?? ?? ?? ??? ?? ? ??? ???.
?: ?? ??
import React, { Component } from 'react'; class Welcome extends Component { render() { return <h1>Hello, {this.props.name}!</h1>; } } // Usage <Welcome name="Alice" />;
???? ??
React? ?? ?? ??? ? ?? ??? ??? ?? ???? ??? UI? ????? ?????.
?: ??? ????
import React, { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); return ( <div> <p>Count: {count}</p> <button onClick={() => setCount(count + 1)}>Increment</button> </div> ); }
??? ????? ?? ?? ???
??? ?? ???? ???, ???? ? ??? ?? ???? ??? ???? ?? ?? ???? ???? ????. ??? ?? ??? ?? useEffect? ?? React ??? ??? ?? ?? ???? ?????.
?: ?? ?? ??
import React, { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); return ( <div> <p>Count: {count}</p> <button onClick={() => setCount(count + 1)}>Increment</button> </div> ); } // Usage;
?: useEffect? ??? ?? ??
function Greeting({ name }) { return <h1>Welcome, {name}!</h1>; } function App() { return <Greeting name="John" />; } // Renders: Welcome, John!
React? ??? ??
React? ???? ??? ??? ??????. ??? ???? ??? props? ???? ???? ??? ? ?????.
?: ?? ???
function Header() { return <header><h1>My Website</h1></header>; } function Main() { return <main><p>This is the main content.</p></main>; } function Footer() { return <footer><p>? 2024 My Website</p></footer>; } function App() { return ( <div> <Header /> <Main /> <Footer /> </div> ); } // Usage <App />;
?: ?? ??
import React, { Component } from 'react'; class Timer extends Component { componentDidMount() { console.log('Timer mounted'); } componentWillUnmount() { console.log('Timer unmounted'); } render() { return <p>Timer running...</p>; } } // Usage <Timer />;
??? ???
React? ???? ?????? ??? ?? ???? ?? ??? ??? ???? ? ????.
?: ??? ???
import React, { useEffect } from 'react'; function Timer() { useEffect(() => { console.log('Timer mounted'); return () => console.log('Timer unmounted'); }, []); return <p>Timer running...</p>; } // Usage <Timer />;
?? ? ?
React?? ??? ???? ? React? ?? ??? ??? ? ??? ? ??? ??? ?? ???? ?? ?????.
?: ?? ???
function Button() { function handleClick() { alert('Button clicked!'); } return <button onClick={handleClick}>Click Me</button>; } // Usage <Button />;
??? ??? ????
React? ???? ??? ?? ?????? ???? ???? ? ?? ?? ?? ??? ?????.
?: ??? ??? ?? ????
import React, { useState } from 'react'; function InputExample() { const [text, setText] = useState(''); function handleChange(event) { setText(event.target.value); } return ( <div> <input type="text" value={text} onChange={handleChange} /> <p>You typed: {text}</p> </div> ); } // Usage <InputExample />;
??
React? ?? ? ??????? ???? ?? ??? ?????. ??, ?? ? ??? ?? ??? ??? ?? ?? ?? ????? ???? ???? ????? ??? ??? UI? ?? ? ????. React? ?? ??? ??? ??? ????? ?????? ???? ???? ?? ?? ??? ?????? ????? ??? ??? ??? ??? ? ????. ??? ??? ????? ? ?? React ?? ???? ????? ??? ??? ???? ??? ?????! ?
? ??? React ?? ? ???? ?? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JavaScript? ??? ?? ????? ??? ?? ??? ??? ?? ?? ?? ????? ?? ???? ???? ?????. ??? ?? ???? ?? ??? ?? ??? ???? ???? ?? ?? ???? ???? ?????. ?? ??, ??? ? ?? ???? ??? (? : ??? null? ??) ?? ??? ????? ??????. ??? ??? ???? ??? ??? ????. closure?? ?? ??? ?? ??; ? ??? ??? ?? ?? ???? ?? ???? ????. V8 ??? ?? ???, ?? ??, ??/?? ???? ?? ??? ?? ??? ??? ????? ?? ??? ?? ??? ????. ?? ?? ???? ??? ??? ??? ??? ???? ????? ?? ?? ???? ?? ???????.

Node.js?? HTTP ??? ???? ? ?? ???? ??? ????. 1. ?? ????? ????? ??? ??? ? ?? ????? ?? ?? ? https.get () ??? ?? ??? ??? ? ?? ????? ?? ??? ?????. 2.axios? ??? ???? ? ?? ??????. ??? ??? ??? ??? ??? ??? ???/???, ?? JSON ??, ???? ?? ?????. ??? ?? ??? ????? ?? ????. 3. ?? ??? ??? ??? ??? ???? ???? ??? ??? ???? ?????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

?? JavaScript ??? ??? ??? ?????? ?? ??? ?? ?? ??? ?? ???? ????. 1. ??? ???? ???? ?? ??? ?? ? ? ???? ??? ??? ?? ? ?? ????? ?????. 2. Angular? ?????? ??? ?? ???? ? ?? ?? ??? ??? ??? ???? ?????. 3. VUE? ???? ?? ??? ???? ?? ?? ??? ?????. ?? ?? ?? ??, ? ??, ???? ???? ? SSR? ???? ??? ??? ??? ???? ? ??? ?????. ???, ??? ??? ??? ????? ????. ??? ??? ??? ??? ?? ????.

?????, JavaScript ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

iife (?? invokedfunctionexpression)? ?? ??? ???? ?? ????? ??? ???? ?? ??? ????? ?? ??? ? ?????. ??? ?? ?? ??? ???? ? ?? ??? ??? ?? (function () {/code/}) ();. ?? ???? ??? ?????. 1. ?? ??? ??? ?? ???? ?? ??? ??? ?????. 2. ?? ??? ??? ???? ?? ?? ??? ????. 3. ?? ?? ??? ????? ?? ???? ???????? ?? ? ??. ???? ?? ???? ?? ??? ES6 ??? ??? ??? ?? ? ??? ????? ??? ? ???? ???????.

??? JavaScript?? ??? ??? ?????? ?? ???????. ?? ??, ?? ?? ? ??? ??? ?? ????? ????? ?????. 1. ?? ??? ??? ????? ???? ??. ()? ?? ??? ??? ?????. ?. ()? ?? ??? ?? ??? ??? ?? ? ? ????. 2. ?? ??? .catch ()? ???? ?? ??? ??? ?? ??? ??????, ??? ???? ???? ????? ??? ? ????. 3. Promise.all ()? ?? ????? (?? ?? ?? ? ??????? ??), Promise.Race () (? ?? ??? ?? ?) ? Promise.AllSettled () (?? ??? ???? ??)

Cacheapi? ?????? ?? ???? ??? ???? ???, ?? ??? ??? ?? ???? ? ??? ?? ? ???? ??? ??????. 1. ???? ????, ??? ??, ?? ?? ?? ???? ???? ??? ? ????. 2. ??? ?? ?? ??? ?? ? ? ????. 3. ?? ?? ?? ?? ?? ??? ??? ?? ?????. 4. ??? ???? ?? ?? ???? ?? ?? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 5. ?? ???? ??, ??? ??? ? ??? ??, ?? ??? ? ?? ???? ???? ???? ? ?? ?????. 6.?? ??? ?? ?? ?? ??, ???? ?? ? HTTP ?? ????? ?????? ???????.
