React ????? ?? ?????
Javascript?? ??? ??? ?? ?? ??? ?????.
??? ?? React? ??? ??? ???? ????
React ????? ?? ??? ???? ?????? ?? ???? React ?? ?? ???? ???? ? ?? ?? ?? ??? ???. ? ??? ????? ????? ??? ???? ??????. ? ????? Context? ??? ????? ???? ??? ???? ???? ???? ????? ???? ??? ???????.
??? ????? ??????
React Context? ?? ???? ???? props? ??? ?? ?? ?? ?? ??? ?? ???? ???? ??? ?????. React.createContext? ???? ???? ???? ??? ??? ?????. Provider ?? ??? ?? ???? Consumer ?? useContext ??? ??? ?? ?? ??? ?? ?? ???? ? ????.
???? ?? ??? ????.
import React, { createContext, useContext } from "react"; const ThemeContext = createContext("light"); function App() { return ( <ThemeContext.Provider value="dark"> <Toolbar /> </ThemeContext.Provider> ); } function Toolbar() { return <ThemedButton />; } function ThemedButton() { const theme = useContext(ThemeContext); return <button>{`Theme: ${theme}`}</button>; } export default App;
? ??? ThemedButton? ??? ?? props? ????? ???? ??? ThemeContext.Provider?? ???? ?? ?? ???? ? ????.
? ??? ??? ???????
????? ????? ?? ????? ???? ?? ??? ??? ? ????. Context.Provider?? ???? ?? ???? ?? ????? ???? ?? ?? ??? ?? ??????. ??? ????????? ?? ?? ?? ??? ????? ?? ???? ? ????.
?? ?? ????? ???? ??? ??? ??? ?? ?? ?? ????? ???? ??? ?????. ? ?? ??? ??? ???? ? ??? ?? ?? ?? ??? ???? ???? ?? ?????.
?? ??? ??
Radix Primitives? ?? ??????? ???? ?? ?? ?? ?? ??? ??? ????? ??????. ??? ?? ??? ????? Context? ???? ??? ?? ??? ???? ??? ????. ??? ??? ?? ??? ?? ???? ??? ???? ???? ??? ??? ? ????.
?? ?????? ?
Radix Primitives? ?? ??? ?? ??? ???? ?? ?? ???? ?? API? ?????. ?? ??? ????.
<AlertDialog.Root> <Dialog.Root> <Dialog.Trigger /> <Dialog.Content> <AlertDialog.Trigger /> {/* note the alert trigger in dialog content */} </Dialog.Content> </Dialog.Root> <AlertDialog.Content /> </AlertDialog.Root>
??? ??? ???? ??? AlertDialog? AlertDialog ?? ??? ???? ?? ?? ??? ?? Dialog? ???? ?????. ?, AlertDialog.Root? Dialog.Root??? DialogContext? AlertDialogContext? ?? ?????.
? ????? AlertDialog.Trigger(Dialog.Trigger??? ?)? useContext(DialogContext)? ?? ??? ????? ???? AlertDialog.Root ?? Dialog.Root? ????? ?? ? ????. ????? AlertDialog.Trigger? ???? ??? ?? ???? ?? Dialog.Content? ??? ? ????.
??? ??? ???? ???
??? ??? ???? ?? Radix Primitives? ??? ??? ????? ?????. ??? ??? ????? AlertDialog.Trigger? AlertDialog ???? ?? ???? ???? ??? ?? ???? ??? ????? ???? ??? ?????. ?? ????? ? ????? ???? ?? __scopeDialog? ?? ??? ?? ??? ?? Dialog ?? ??? ?????? ?????. ?? ?? Dialog ?? ??? useContext ???? ? ?? ????? ???? ??? ?????.
radix ui github ???? ?? ??:
https://github.com/radix-ui/primitives/blob/dae8ef4920b45f736e2574abf23676efab103645/packages/react/dialog/src/Dialog.tsx#L69
??? Radix UI?? ??? ??? ????? ???? ??? ???? ????.
-
?? ??: createScope ????? ? ?? ?? ?? ?? ?? ??? ?? ??? ??????? ?????. ??? ?? ? ???? ??? ???? ?? ???? ??? ???? ????.
import React, { createContext, useContext } from "react"; const ThemeContext = createContext("light"); function App() { return ( <ThemeContext.Provider value="dark"> <Toolbar /> </ThemeContext.Provider> ); } function Toolbar() { return <ThemedButton />; } function ThemedButton() { const theme = useContext(ThemeContext); return <button>{`Theme: ${theme}`}</button>; } export default App;
-
??? ??? ???: ????? ??? ? ??? ?????. ?? ???? ???? ??? ??????? ??????.
<AlertDialog.Root> <Dialog.Root> <Dialog.Trigger /> <Dialog.Content> <AlertDialog.Trigger /> {/* note the alert trigger in dialog content */} </Dialog.Content> </Dialog.Root> <AlertDialog.Content /> </AlertDialog.Root>
-
??? ??: useDialogScope? ?? ?? ?? ??? ???? ??? ??? ?????? ?????? ?????.
import { createScope } from '@radix-ui/react-context'; const [createDialogContext, useDialogScope] = createScope('Dialog');
??? ??? ????? ??
???? ?? ??: ???? ??? ???? AlertDialog.Trigger? ?? ?? ??? ?? ???? ?? ??? ???? ?? ?? ????(AlertDialogContext)? ?? ? ????.
??? ??: ??? ??? ????? ?? ?? ??? ???? ???? ??? ? ???? ?? ??? ??? ? ????.
????: ???? ?? ?? ??? ???? ?? ?? ??(?: Dialog.Trigger)? ???? ? ????.
??? ???? ??
??? ????:
AlertDialog.Root? ?? ??? ?? ??? ????? ??? ??? AlertDialogContext? ?????.
??? Dialog.Root? AlertDialog.Trigger? ?? ?? ??? ????? ????? ?? ?? ?????.
? ??? ??? ??? ?? ?? ?? ??? ???? ?? ?? ?? ???? ????? ???? Radix UI? ?? ?????.
????:
https://dev.to/romaintrotard/use-context-selector-demystified-4f8e
https://github.com/radix-ui/primitives
https://react.dev/reference/react/createContext
? ??? ?? ?? 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 ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

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

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 ?? ????? ?????? ???????.
