React?? ??? ?? ??
??? ?? ??? ?? API, ?????? ?? ?? ???? ??? ? React ??????? ???? ?? ?????. API?? ???? ????? ??? ???? ?? ?? JavaScript ??? ?? ??????? React? ?? ???? ??? ? ?? ??? ??? ?????.
? ?????? async/await, Promise ? ?? React ?? ??? ???? React?? ??? ??? ???? ??? ??? ???????.
1. ??? ??? useEffect ??
React? useEffect ??? ?? ??? ???? ? ???? ???? ?? ?? ???? ???? ? ?????. Hook ??? Promise? ?? ??? ? ???? Effect ???? ??? ??? ?????.
useEffect ???? async/await ??
useEffect ??? ???? ???? ???? ?? ??? ??? ???? ??? ??? ????.
import React, { useState, useEffect } from 'react'; const API_URL = 'https://jsonplaceholder.typicode.com/posts'; // Example API const AsyncFetchExample = () => { const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); // Using async/await inside useEffect useEffect(() => { const fetchData = async () => { try { const response = await fetch(API_URL); if (!response.ok) { throw new Error('Failed to fetch data'); } const data = await response.json(); setPosts(data); } catch (error) { setError(error.message); } finally { setLoading(false); } }; fetchData(); // Call the async function }, []); // Empty dependency array means this effect runs once when the component mounts if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> <h1>Posts</h1> <ul> {posts.map((post) => ( <li key={post.id}> <h2>{post.title}</h2> <p>{post.body}</p> </li> ))} </ul> </div> ); }; export default AsyncFetchExample;
- async/await: ?? ?? ???? ????? ?????.
- ?? ??: ??? ???? ??? ???? ?????.
- ?? ??: ??? ???? ???? ??? ??? ?? ???? ?????.
? async/await? ??????
- ?? ???: .then() ? .catch() ??? ???? ????.
- ? ???? ?? ??: ??? ? ???? ???? ??? ? ????.
2. ??? ??? ?? ?? ??
? ?? ???? ?? ??? Promise? then() ? catch()? ?? ?? ???? ????. ? ??? async/await?? ? ????? ??? ??? ???? ?? JavaScript?? ??? ?? ?????.
?? ?? Promise ??Effect
??? ??? ??? Promise? then()? ???? ????.
import React, { useState, useEffect } from 'react'; const API_URL = 'https://jsonplaceholder.typicode.com/posts'; const AsyncFetchWithPromise = () => { const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetch(API_URL) .then((response) => { if (!response.ok) { throw new Error('Failed to fetch data'); } return response.json(); }) .then((data) => { setPosts(data); setLoading(false); }) .catch((error) => { setError(error.message); setLoading(false); }); }, []); if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> <h1>Posts</h1> <ul> {posts.map((post) => ( <li key={post.id}> <h2>{post.title}</h2> <p>{post.body}</p> </li> ))} </ul> </div> ); }; export default AsyncFetchWithPromise;
- then(): Promise? ???? ??? ?????.
- catch(): API ?? ?? ???? ?? ??? ?????.
- ?? ??: ??? ???? ?? ???? ?????.
3. ??? ??? ??? useReducer ??
? ??? ?? ??? ??? ??? ???? ?? ?? ??(??, ??, ?? ?)? ???? ?? ?? useReducer? ?? ??? ???? ??? ?????.
??? ??? useReducer ??
import React, { useState, useEffect } from 'react'; const API_URL = 'https://jsonplaceholder.typicode.com/posts'; // Example API const AsyncFetchExample = () => { const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); // Using async/await inside useEffect useEffect(() => { const fetchData = async () => { try { const response = await fetch(API_URL); if (!response.ok) { throw new Error('Failed to fetch data'); } const data = await response.json(); setPosts(data); } catch (error) { setError(error.message); } finally { setLoading(false); } }; fetchData(); // Call the async function }, []); // Empty dependency array means this effect runs once when the component mounts if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> <h1>Posts</h1> <ul> {posts.map((post) => ( <li key={post.id}> <h2>{post.title}</h2> <p>{post.body}</p> </li> ))} </ul> </div> ); }; export default AsyncFetchExample;
- useReducer: ??? ??? ??? ?? ?? ??? ?? ?? ?????.
- ?? ??: ??, ??, ?? ? ??? ??? ????? ?????.
4. ??? ??? ??? ??? ???? ??? ?? ?? ??
?? ???? ?? ?? ???? ??? ??? ????? ?? ?? ????. ??? ?? ??? ??? ?? ??? ????? ??? ? ??? ???? ??? ??? ?????.
??? ????? ?? ??? ?? ?? ??
import React, { useState, useEffect } from 'react'; const API_URL = 'https://jsonplaceholder.typicode.com/posts'; const AsyncFetchWithPromise = () => { const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetch(API_URL) .then((response) => { if (!response.ok) { throw new Error('Failed to fetch data'); } return response.json(); }) .then((data) => { setPosts(data); setLoading(false); }) .catch((error) => { setError(error.message); setLoading(false); }); }, []); if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> <h1>Posts</h1> <ul> {posts.map((post) => ( <li key={post.id}> <h2>{post.title}</h2> <p>{post.body}</p> </li> ))} </ul> </div> ); }; export default AsyncFetchWithPromise;
- ??? ?? ??(useFetch): ??? ????, ?? ?? ? ?? ??? ?? ??? ??????.
- ????: ???? ???? ?? ?? ?? ???? ??? ???? ? ????.
5. ??
React?? ??? ??? ???? ?? ?? ? ??????? ???? ? ??????. useEffect, useReducer ? ??? ?? ??? ?? ??? ???? ??? ??? ?? ???? ??? ???? ??? ??? ??? ??? ? ????. ??? ????, ?? ??, ??? ??? ?? ?? ? ?? ??? ?? React? ??? ??? ????? ??? ? ?? ??? ??? ?????.
? ??? useEffect, Promise ? Custom Hooks? ???? 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?? ??? ??? ?? ? ? ?? ??? ???????. 1. ?? ??? ??? ???? ?? ??? ????. ISO ?? ???? ???? ???? ???? ?? ????. 2. ?? ??? ?? ???? ??? ?? ???? ??? ? ??? ? ?? 0?? ????? ?? ??????. 3. ?? ?? ???? ???? ???? ?? ?????? ??? ? ????. 4. Luxon? ?? ???? ???? ?????? ???? ?? ????. ??? ?? ???? ????? ???? ??? ????? ?? ? ????.

TAGGSATTHEBOTTOMOFABLOGPOSTORWEBPAGESERVESPRACTICALPURSEO, USEREXPERIENCE, andDESIGN.1.ITHELPSWITHEOBYOWNSESPORENGENSTOESTOCESKESKERKESKERKERKERDER-RELEVANTTAGSWITHOUTHINGTEMAINCONTENT.2.ITIMPROVESEREXPERKEEPINGTOPONTEFOCUSOFOFOFOCUSOFOFOFOCUCUSONTHEATECLL

??? ?? ? ??? DOM?? ??? ??? ? ?????. ??? ?? ????? ?? ??????, ??? ?? ???? ?? ????????. 1. ??? ??? addeventListener? usecapture ?? ??? true? ???? ?????. 2. ??? ??? ?? ???? usecapture? ???? ????? ?????. 3. ??? ??? ??? ??? ???? ? ??? ? ????. 4. ??? ?? ?? ?? ??? ?? ??? ??????? ??? ???? ?????. 5. ??? ?? ?? ?? ??? ?? ???? ?? ???? ? ??? ? ????. ? ? ??? ???? ???? JavaScript? ??? ??? ??? ????? ???? ???? ??? ??????.

JavaScript ?? ????? ??????? ??? ?? ??? ??? ????? ?? ??? ????. ????? ??? ?????. 1. ?? ?? (CodesPlitting) ??, ?? ??? React.lazy ()? ?? ?? ?? ?? ??? ????? ??? ???? ? ?? ????? ??? ?? ??? ???????. 2. ???? ?? ?? (???)? ????, ES6 ?? ????? ???? "Dead Code"? ???? ?? ? ????? ?? ??? ??? ? ???????. 3. ?? ??? ???? ???? GZIP/BROTLI ? TERSER? JS? ???? ??? ????? ???? ?? ???? ??? ? ? ??????. 4. ??? ???? ???? day.js ? fetch? ?? ?? ?????? ??????.

ES ??? CommonJS? ?? ???? ?? ?? ? ?? ???????. 1. Commonjs? ????????? Node.js ?? ? ??? ?????. 2.ES ??? ???????? ????? ?? ???? ??? ?????. 3. ??, ES ??? ?? ??/????? ???? ??? ??? ?????? CommonJS? Quiew/Module.exports? ???? ???? ???? ?? ? ? ????. 4. Commonjs? Express? ?? ???? Node.js ? ?????? ?? ???? ?? ???? ?? ES ??? ?? ??? ?? ??? ?? ? Node.jsv14? ?????. 5. ?? ? ? ??? ?? ??? ??? ? ????.

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

???? ?? ?? ??? JavaScript ??? ????? ?? 4 ?? ??????. 1. ???? ??? ?? ?? ??? ???? ?? ??? Count? ?? ??? ?? ???? ?? ??? FetchData ()? ?? ??? ???? ??? ??? ??? ????? ?? PascalScase? ?? ?????. 2. ???? ? ??? ???? ??? ? ??? ??? ??? Formatuser, SaveUser ? RenderUser? ???? ?? ?? ? ??? ?????. 3. Page? userprofile, Userstats ? React? ?? ???? ???? ? ??? ? ?? ???? ????? ??????. 4. ?? ?? ? ???? ??? ??? ? ???? ??? ??? ??????.

VAR, Let ? Const? ???? ??, ?? ? ?? ?????. 1.var? ?? ??????? ?? ???? ?? ? ??? ?????. 2. let? ?? ?? ????? ?? ?? ???? ?? ? ??? ???? ????. 3. ???? ?? ?? ???? ?? ??????? ? ?? ? ? ??? ?? ??? ?? ?? ??? ? ????. ?? const? ???? ??? ??? ? LET? ???? VAR? ???? ????.
