From aaa5f08edbd1bbcf2e9c3c17cc7691e312abd671 Mon Sep 17 00:00:00 2001 From: Ravid Levy <61316827+Ravid-Levy@users.noreply.github.com> Date: Sat, 21 Feb 2026 00:47:46 +0200 Subject: [PATCH 01/10] Translate docs to Hebrew and normalize React terminology --- CONTRIBUTE.md | 94 + CONTRIBUTING.md | 172 +- README.md | 85 +- package.json | 3 +- scripts/fix-learn-mdx.mjs | 77 + scripts/translate-learn.mjs | 113 + src/components/Layout/Footer.tsx | 38 +- src/components/Layout/HomeContent.js | 327 +- src/components/Layout/TopNav/TopNav.tsx | 30 +- src/components/Seo.tsx | 4 +- ...a-fetching-with-react-server-components.md | 18 +- .../blog/2021/06/08/the-plan-for-react-18.md | 64 +- .../blog/2021/12/17/react-conf-2021-recap.md | 104 +- ...-what-we-have-been-working-on-june-2022.md | 66 +- ...what-we-have-been-working-on-march-2023.md | 84 +- src/content/blog/2023/05/03/react-canaries.md | 85 +- ...t-we-have-been-working-on-february-2024.md | 91 +- src/content/blog/index.md | 38 +- src/content/community/acknowledgements.md | 24 +- src/content/community/docs-contributors.md | 68 +- src/content/community/index.md | 28 +- src/content/community/meetups.md | 5 +- src/content/community/team.md | 54 +- src/content/community/versioning-policy.md | 160 +- src/content/community/videos.md | 52 +- src/content/errors/377.md | 8 +- src/content/errors/generic.md | 6 +- src/content/errors/index.md | 6 +- src/content/index.md | 2 +- .../learn/add-react-to-an-existing-project.md | 70 +- src/content/learn/adding-interactivity.md | 93 +- src/content/learn/describing-the-ui.md | 111 +- src/content/learn/editor-setup.md | 44 +- src/content/learn/escape-hatches.md | 117 +- .../extracting-state-logic-into-a-reducer.md | 231 +- .../importing-and-exporting-components.md | 125 +- src/content/learn/index.md | 150 +- src/content/learn/installation.md | 37 +- .../javascript-in-jsx-with-curly-braces.md | 111 +- .../learn/lifecycle-of-reactive-effects.md | 351 +- src/content/learn/managing-state.md | 85 +- .../queueing-a-series-of-state-updates.md | 144 +- src/content/learn/react-developer-tools.md | 35 +- .../learn/reacting-to-input-with-state.md | 199 +- .../learn/removing-effect-dependencies.md | 317 +- src/content/learn/render-and-commit.md | 108 +- .../learn/reusing-logic-with-custom-hooks.md | 309 +- .../scaling-up-with-reducer-and-context.md | 111 +- .../learn/separating-events-from-effects.md | 253 +- .../learn/sharing-state-between-components.md | 131 +- .../learn/start-a-new-react-project.md | 80 +- .../learn/state-a-components-memory.md | 175 +- src/content/learn/state-as-a-snapshot.md | 135 +- src/content/learn/thinking-in-react.md | 177 +- src/content/learn/typescript.md | 147 +- .../learn/understanding-your-ui-as-a-tree.md | 95 +- src/content/learn/updating-arrays-in-state.md | 3 +- .../learn/updating-objects-in-state.md | 5 +- src/content/learn/writing-markup-with-jsx.md | 9 +- .../learn/you-might-not-need-an-effect.md | 3 +- src/content/learn/your-first-component.md | 13 +- .../reference/react-dom/client/index.md | 10 +- .../reference/react-dom/components/index.md | 78 +- .../reference/react-dom/components/meta.md | 40 +- .../reference/react-dom/components/option.md | 27 +- .../react-dom/components/progress.md | 22 +- .../reference/react-dom/components/script.md | 74 +- .../reference/react-dom/components/style.md | 46 +- .../reference/react-dom/components/title.md | 37 +- src/content/reference/react-dom/flushSync.md | 44 +- .../reference/react-dom/hooks/index.md | 13 +- .../reference/react-dom/hooks/useFormState.md | 54 +- .../react-dom/hooks/useFormStatus.md | 66 +- src/content/reference/react-dom/hydrate.md | 60 +- src/content/reference/react-dom/index.md | 47 +- src/content/reference/react-dom/preconnect.md | 34 +- .../reference/react-dom/prefetchDNS.md | 36 +- src/content/reference/react-dom/preinit.md | 56 +- .../reference/react-dom/preinitModule.md | 44 +- src/content/reference/react-dom/preload.md | 72 +- .../reference/react-dom/preloadModule.md | 44 +- src/content/reference/react-dom/render.md | 52 +- .../reference/react-dom/server/index.md | 32 +- .../react-dom/server/renderToNodeStream.md | 32 +- .../react-dom/server/renderToStaticMarkup.md | 34 +- .../server/renderToStaticNodeStream.md | 36 +- .../react-dom/server/renderToString.md | 65 +- .../react-dom/unmountComponentAtNode.md | 24 +- src/content/reference/react/Fragment.md | 38 +- src/content/reference/react/Profiler.md | 45 +- src/content/reference/react/PureComponent.md | 32 +- src/content/reference/react/apis.md | 14 +- src/content/reference/react/components.md | 18 +- src/content/reference/react/createContext.md | 63 +- src/content/reference/react/createElement.md | 68 +- src/content/reference/react/createFactory.md | 52 +- src/content/reference/react/createRef.md | 38 +- src/content/reference/react/directives.md | 10 +- .../experimental_taintObjectReference.md | 42 +- .../react/experimental_taintUniqueValue.md | 62 +- .../react/experimental_useEffectEvent.md | 8 +- src/content/reference/react/hooks.md | 70 +- src/content/reference/react/index.md | 30 +- src/content/reference/react/isValidElement.md | 56 +- src/content/reference/react/lazy.md | 42 +- src/content/reference/react/legacy.md | 22 +- .../reference/react/startTransition.md | 36 +- src/content/reference/react/use-server.md | 98 +- src/content/reference/react/useDebugValue.md | 32 +- src/content/reference/react/useId.md | 64 +- .../reference/react/useImperativeHandle.md | 36 +- .../reference/react/useInsertionEffect.md | 60 +- src/content/reference/react/useOptimistic.md | 26 +- src/content/warnings/invalid-aria-prop.md | 10 +- .../warnings/invalid-hook-call-warning.md | 68 +- src/content/warnings/react-test-renderer.md | 6 +- src/content/warnings/special-props.md | 6 +- src/content/warnings/unknown-prop.md | 22 +- src/pages/[[...markdownPath]].js | 7 +- src/sidebarBlog.json | 44 +- src/sidebarCommunity.json | 20 +- src/sidebarHome.json | 38 +- src/sidebarLearn.json | 94 +- src/sidebarReference.json | 16 +- yarn.lock | 13402 ++++++++-------- 125 files changed, 11070 insertions(+), 10784 deletions(-) create mode 100644 CONTRIBUTE.md create mode 100644 scripts/fix-learn-mdx.mjs create mode 100644 scripts/translate-learn.mjs diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md new file mode 100644 index 000000000..3dd4593fb --- /dev/null +++ b/CONTRIBUTE.md @@ -0,0 +1,94 @@ +# CONTRIBUTE + +מסמך זה מגדיר תהליך מלא לתרגום `he.react.dev` לעברית. + +## מטרה + +לתרגם את כל דפי התיעוד והתוכן באתר לעברית, תוך שמירה על קוד, API names, פונקציות, מזהים טכניים ושמות חבילות באנגלית. + +## עקרונות תרגום + +1. קוד נשאר באנגלית: + - בלוקי קוד (```) + - Inline code (טקסט בין `) + - שמות פונקציות, hooks, APIs, ספריות, נתיבים ופקודות +2. טקסט הסבר, כותרות ופסקאות מתורגמים לעברית מלאה. +3. שמירה על מבנה Markdown/MDX: + - אין למחוק Frontmatter + - אין לשנות `id`, `permalink`, anchors קיימים אלא אם יש החלטה מסודרת בפרויקט +4. קישורים: + - כתובות URL נשארות כפי שהן + - טקסט הקישור מתורגם לעברית כשאפשר +5. מונחים טכניים: + - React, JSX, Hooks, State, Props יכולים להישאר באנגלית אם התרגום פוגע בבהירות + - להשתמש במינוחים עקביים לאורך כל האתר + +## היקף קבצים לתרגום + +1. תוכן האתר: + - `src/content/**/*.md` +2. דפי קהילה ובלוג: + - `src/content/community/**/*.md` + - `src/content/blog/**/*.md` +3. דפי API ו-Reference: + - `src/content/reference/**/*.md` +4. קבצי מעטפת תיעוד: + - `README.md` + - `CONTRIBUTING.md` (או גרסה עברית ייעודית) + +## תהליך עבודה מומלץ + +1. יצירת ענף עבודה: + - `git checkout main` + - `git pull origin main` + - `git checkout -b docs/hebrew-full-translation` +2. תרגום לפי אצוות קטנות (batch): + - כל PR יכלול תחום אחד: `learn`, `reference`, `community` וכו' +3. בדיקה מקומית: + - `yarn` + - `yarn dev` + - פתיחה: `http://localhost:3000` +4. בדיקות איכות: + - `yarn check-all` +5. Commit ברור לכל אצווה: + - `git add -A` + - `git commit -m "Translate learn section to Hebrew (batch 1)"` + +## צ'ק ליסט לכל קובץ מתורגם + +1. הכותרת תורגמה לעברית ברורה. +2. הפסקאות תורגמו בלי לשנות משמעות טכנית. +3. קוד נשאר זהה למקור. +4. טבלאות, רשימות ובלוקי הערות מוצגים נכון. +5. קישורים תקינים. +6. אין שגיאות Markdown/MDX. + +## QA לפני PR + +1. מעבר ידני על הדפים ששונו (Desktop + Mobile). +2. בדיקת עקביות טרמינולוגית מול דפים סמוכים. +3. חיפוש מהיר למונחים שלא תורגמו בטעות: + - לדוגמה: משפטים ארוכים באנגלית מחוץ לבלוקי קוד. +4. וידוא שלא נשברו anchors של כותרות קיימות. + +## מדיניות PR + +1. PR קטן עד בינוני עדיף על PR ענק. +2. בכותרת PR לציין את האזור המתורגם. +3. בתיאור PR לכלול: + - רשימת קבצים + - סיכום החלטות טרמינולוגיה + - צילומי מסך במידת הצורך + +## סטטוס תרגום (תבנית לעדכון) + +- `learn`: in progress +- `reference`: pending +- `community`: pending +- `blog`: pending +- `warnings/errors`: pending +- `README/CONTRIBUTING`: in progress + +## הערה חשובה + +תרגום מלא לכל האתר הוא עבודה רחבה. מומלץ לבצע באצוות מסודרות ולשמור על איכות תרגום גבוהה ועקבית במקום שינוי חד-פעמי גדול מדי. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e861af35..af4c9ad3f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,135 +1,125 @@ # Contributing -Thank you for your interest in contributing to the React Docs! +תודה על הרצון לתרום לתיעוד של React. ## Code of Conduct -Facebook has adopted a Code of Conduct that we expect project -participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct) -so that you can understand what actions will and will not be tolerated. +יש לפעול לפי קוד ההתנהגות של הפרויקט: +https://code.facebook.com/codeofconduct -## Technical Writing Tips +## הנחיות כתיבה -This is a [good summary](https://medium.com/@kvosswinkel/coding-like-a-journalist-ee52360a16bc) for things to keep in mind when writing technical docs. +לתיעוד יש אזורים שונים עם מטרות שונות, ולכן גם סגנון שונה. כשעורכים דף קיים, שומרים על הטון של אותו אזור. -## Guidelines for Text +1. `Learn React`: + - בנוי כלמידה הדרגתית + - יש להימנע מתלויות מחזוריות בין דפים + - קורא אמור להיות מסוגל לעבור מהדף הראשון לאחרון ללא "קפיצות קדימה" +2. `API Reference`: + - מאורגן לפי APIs + - צריך להיות מקיף ומדויק + - מקרי קצה והמלצות מפורטות צריכים להופיע כאן -**Different sections intentionally have different styles.** +## הנחיות לקוד בדוגמאות -The documentation is divided into sections to cater to different learning styles and use cases. When editing an article, try to match the surrounding text in tone and style. When creating a new article, try to match the tone of the other articles in the same section. Learn about the motivation behind each section below. +1. העדיפו JSX על `createElement` (אלא אם הדף עוסק ספציפית ב-`createElement`). +2. העדיפו `const`, ואם צריך אז `let`; לא להשתמש ב-`var`. +3. אם אין יתרון ברור ל-ES6 חדש, אפשר להשתמש ב-ES5 ברור ופשוט. +4. לדוגמאות ברמת top-level, לרוב עדיף `function` בשם מאשר arrow function. +5. אין להשתמש ביכולות לא סטנדרטיות בלי לציין במפורש שהן ניסיוניות. -**[Learn React](https://react.dev/learn)** is designed to introduce fundamental concepts in a step-by-step way. Each individual article in Learn React builds on the knowledge from the previous ones, so make sure not to add any "cyclical dependencies" between them. It is important that the reader can start with the first article and work their way to the last Learn React article without ever having to "look ahead" for a definition. This explains some ordering choices (e.g. that state is explained before events, or that "thinking in React" doesn't use refs). Learn React also serves as a reference manual for React concepts, so it is important to be very strict about their definitions and relationships between them. +## סגנון קוד -**[API Reference](https://react.dev/reference/react)** is organized by APIs rather than concepts. It is intended to be exhaustive. Any corner cases or recommendations that were skipped for brevity in Learn React should be mentioned in the reference documentation for the corresponding APIs. +1. להשתמש ב-`;` +2. אין רווח בין שם פונקציה לסוגריים +3. במקרה של ספק, להיצמד ל-Prettier -**Try to follow your own instructions.** +## הדגשת שורות בקוד Markdown -When writing step-by-step instructions (e.g. how to install something), try to forget everything you know about the topic, and actually follow the instructions you wrote, a single step at time. Often you will discover that there is implicit knowledge that you forgot to mention, or that there are missing or out-of-order steps in the instructions. Bonus points for getting *somebody else* to follow the steps and watching what they struggle with. Often it would be something very simple that you have not anticipated. +שפת הדגשה: -## Guidelines for Code Examples - -### Syntax - -#### Prefer JSX to `createElement`. - -Ignore this if you're specifically describing `createElement`. - -#### Use `const` where possible, otherwise `let`. Don't use `var`. - -Ignore this if you're specifically writing about ES5. - -#### Don't use ES6 features when equivalent ES5 features have no downsides. - -Remember that ES6 is still new to a lot of people. While we use it in many places (`const` / `let`, classes, arrow functions), if the equivalent ES5 code is just as straightforward and readable, consider using it. - -In particular, you should prefer named `function` declarations over `const myFunction = () => ...` arrows for top-level functions. However, you *should* use arrow functions where they provide a tangible improvement (such as preserving `this` context inside a component). Consider both sides of the tradeoff when deciding whether to use a new feature. - -#### Don't use features that aren't standardized yet. - -For example, **don't** write this: - -```js -class MyComponent extends React.Component { - state = {value: ''}; - handleChange = (e) => { - this.setState({value: e.target.value}); - }; -} -``` - -Instead, **do** write this: - -```js -class MyComponent extends React.Component { - constructor(props) { - super(props); - this.handleChange = this.handleChange.bind(this); - this.state = {value: ''}; - } - handleChange(e) { - this.setState({value: e.target.value}); - } -} -``` - -Ignore this rule if you're specifically describing an experimental proposal. Make sure to mention its experimental nature in the code and in the surrounding text. - -### Style - -- Use semicolons. -- No space between function names and parens (`method() {}` not `method () {}`). -- When in doubt, use the default style favored by [Prettier](https://prettier.io/playground/). - -### Highlighting - -Use `js` as the highlighting language in Markdown code blocks: - -```` +````md ```js // code ``` ```` -Sometimes you'll see blocks with numbers. -They tell the website to highlight specific lines. - -You can highlight a single line: +הדגשת שורה בודדת: -```` +````md ```js {2} function hello() { - // this line will get highlighted + // highlighted } ``` ```` -A range of lines: +טווח שורות: -```` +````md ```js {2-4} function hello() { - // these lines - // will get - // highlighted + // highlighted range } ``` ```` -Or even multiple ranges: +כמה טווחים: -```` +````md ```js {2-4,6} function hello() { - // these lines - // will get - // highlighted + // highlighted lines console.log('hello'); - // also this one + // also highlighted console.log('there'); } ``` ```` -Be mindful that if you move some code in an example with highlighting, you also need to update the highlighting. +אם מזיזים קוד בדוגמה, צריך לעדכן גם את שורות ההדגשה. + +## תהליך עבודה + +### יצירת branch + +1. עברו ל-`main` מכל תיקייה בריפו המקומי: + - `git checkout main` +2. משכו את העדכונים האחרונים: + - `git pull origin main` +3. צרו branch חדש עם שם מתאים: + - `git checkout -b the-name-of-my-branch` + +### ביצוע השינוי + +1. פעלו לפי הוראות `Running locally`. +2. שמרו את הקבצים ובדקו בדפדפן. +3. שינויים בקומפוננטות React תחת `src` ייטענו עם `hot-reload`. +4. שינויים בקובצי Markdown תחת `content` ייטענו עם `hot-reload`. +5. אם עובדים עם plugins, ייתכן שתצטרכו למחוק את תיקיית `.cache` ולהפעיל את השרת מחדש. + +### בדיקות + +1. אם אפשר, בדקו כל שינוי ויזואלי בגרסאות האחרונות של דפדפנים נפוצים, גם בדסקטופ וגם במובייל. +2. הריצו: + - `yarn check-all` +3. הפקודה מריצה `Prettier`, `ESLint` ובדיקת types. + +### Commit ו-Push + +1. בצעו stage ו-commit: + - `git add -A && git commit -m "My message"` +2. העלו את ה-branch: + - `git push my-fork-name the-name-of-my-branch` +3. היכנסו לריפו של `react.dev` ב-GitHub ותראו את ה-branches שהועלו לאחרונה. +4. המשיכו לפי ההנחיות של GitHub לפתיחת PR. +5. אם אפשר, צרפו צילומי מסך לשינויים ויזואליים. לאחר push ל-GitHub יופעל גם preview build. + +## תרגום לעברית + +בעת תרגום דפים: -Don't be afraid to often use highlighting! It is very valuable when you need to focus the reader's attention on a particular detail that's easy to miss. +1. משאירים קוד, שמות APIs, פונקציות ופקודות באנגלית. +2. מתרגמים כותרות, פסקאות והסברים לעברית. +3. שומרים על מבנה Markdown/MDX ועל Frontmatter תקין. +4. שומרים על עקביות מונחים בין דפים. diff --git a/README.md b/README.md index 966131db5..c57e78c64 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,70 @@ # react.dev -This repo contains the source code and documentation powering [react.dev](https://react.dev/). +מאגר זה מכיל את קוד המקור והתיעוד שמפעילים את [react.dev](https://react.dev/). -## Getting started +## התחלה מהירה -### Prerequisites +### דרישות מקדימות 1. Git -1. Node: any 12.x version starting with v12.0.0 or greater -1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/) -1. A fork of the repo (for any contributions) -1. A clone of the [react.dev repo](https://github.com/reactjs/react.dev) on your local machine +2. Node: כל גרסה מסדרת 12.x החל מ-`v12.0.0` ומעלה +3. Yarn: הוראות התקנה באתר של Yarn +4. Fork לריפו (אם מתכוונים לתרום) +5. Clone מקומי של מאגר `react.dev` -### Installation +### התקנה -1. `cd react.dev` to go into the project root -3. `yarn` to install the website's npm dependencies +1. היכנסו לשורש הפרויקט: + - `cd react.dev` +2. התקינו תלויות: + - `yarn` -### Running locally +### הרצה מקומית -1. `yarn dev` to start the development server (powered by [Next.js](https://nextjs.org/)) -1. `open http://localhost:3000` to open the site in your favorite browser +1. הפעלת שרת פיתוח (Next.js): + - `yarn dev` +2. פתיחה בדפדפן: + - `http://localhost:3000` -## Contributing +## תרומה -### Guidelines +### קווים מנחים -The documentation is divided into several sections with a different tone and purpose. If you plan to write more than a few sentences, you might find it helpful to get familiar with the [contributing guidelines](https://github.com/reactjs/react.dev/blob/main/CONTRIBUTING.md#guidelines-for-text) for the appropriate sections. +התיעוד מחולק למספר אזורים עם טון ומטרה שונים. אם אתם כותבים יותר מכמה משפטים, מומלץ לעבור על [הנחיות התרומה](https://github.com/reactjs/react.dev/blob/main/CONTRIBUTING.md#guidelines-for-text) של האזור המתאים. -### Create a branch +### יצירת ענף עבודה -1. `git checkout main` from any folder in your local `react.dev` repository -1. `git pull origin main` to ensure you have the latest main code -1. `git checkout -b the-name-of-my-branch` (replacing `the-name-of-my-branch` with a suitable name) to create a branch +1. `git checkout main` +2. `git pull origin main` +3. `git checkout -b the-name-of-my-branch` -### Make the change +### ביצוע השינוי -1. Follow the ["Running locally"](#running-locally) instructions -1. Save the files and check in the browser - 1. Changes to React components in `src` will hot-reload - 1. Changes to markdown files in `content` will hot-reload - 1. If working with plugins, you may need to remove the `.cache` directory and restart the server +1. עבדו לפי הוראות ההרצה המקומית +2. שמרו קבצים ובדקו בדפדפן +3. Hot reload: + - שינויים בקומפוננטות React תחת `src` + - שינויים בקבצי Markdown תחת `src/content` +4. אם עובדים עם plugins, ייתכן שתצטרכו למחוק `.cache` ולהפעיל מחדש את השרת -### Test the change +### בדיקות -1. If possible, test any visual changes in all latest versions of common browsers, on both desktop and mobile. -2. Run `yarn check-all`. (This will run Prettier, ESLint and validate types.) +1. מומלץ לבדוק שינויים ויזואליים בדפדפנים נפוצים (דסקטופ ומובייל) +2. הריצו: + - `yarn check-all` -### Push it +### העלאה ל-GitHub -1. `git add -A && git commit -m "My message"` (replacing `My message` with a commit message, such as `Fix header logo on Android`) to stage and commit your changes -1. `git push my-fork-name the-name-of-my-branch` -1. Go to the [react.dev repo](https://github.com/reactjs/react.dev) and you should see recently pushed branches. -1. Follow GitHub's instructions. -1. If possible, include screenshots of visual changes. A preview build is triggered after your changes are pushed to GitHub. +1. `git add -A && git commit -m "My message"` +2. `git push my-fork-name the-name-of-my-branch` +3. היכנסו ל-repo ב-GitHub והמשיכו לפי ההוראות לפתיחת PR +4. מומלץ לצרף צילומי מסך לשינויים ויזואליים -## Translation +## תרגום -If you are interested in translating `react.dev`, please see the current translation efforts [here](https://github.com/reactjs/react.dev/issues/4135). +אם אתם מעוניינים לתרגם את `react.dev`, אפשר לראות את מאמצי התרגום הפעילים כאן: +https://github.com/reactjs/react.dev/issues/4135 -## License -Content submitted to [react.dev](https://react.dev/) is CC-BY-4.0 licensed, as found in the [LICENSE-DOCS.md](https://github.com/reactjs/react.dev/blob/main/LICENSE-DOCS.md) file. +## רישיון + +תוכן שנשלח ל-`react.dev` מופץ תחת CC-BY-4.0 כפי שמוגדר ב-`LICENSE-DOCS.md`. diff --git a/package.json b/package.json index 274c2506e..de32a7e19 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "license": "CC", "scripts": { "analyze": "ANALYZE=true next build", - "dev": "next-remote-watch ./src/content", + "dev": "next dev", + "dev:remote-watch": "next-remote-watch ./src/content", "build": "next build && node --experimental-modules ./scripts/downloadFonts.mjs", "lint": "next lint", "lint:fix": "next lint --fix", diff --git a/scripts/fix-learn-mdx.mjs b/scripts/fix-learn-mdx.mjs new file mode 100644 index 000000000..6aa5efd57 --- /dev/null +++ b/scripts/fix-learn-mdx.mjs @@ -0,0 +1,77 @@ +import fs from 'fs'; +import path from 'path'; + +const dir = 'src/content/learn'; +const files = fs.readdirSync(dir).filter((f) => f.endsWith('.md')); + +function slugifyId(raw) { + return raw + .normalize('NFKD') + .replace(/["'`]/g, '') + .replace(/\s+/g, '-') + .replace(/[^\p{L}\p{N}-]/gu, '-') + .replace(/-+/g, '-') + .replace(/^-|-$/g, '') + .toLowerCase(); +} + +for (const f of files) { + const p = path.join(dir, f); + let s = fs.readFileSync(p, 'utf8'); + const original = s; + + // Normalize malformed heading anchor comments. + s = s.replace(/\{\/\*([^*]*?)\*\/\}/g, (m, id) => `{/*${slugifyId(id)}*/}`); + + // Handle broken duplicated heading line fragments like "{/...* {/*...*/}". + s = s.replace(/\{\/[^{\n]*\{\/\*([^*]*?)\*\/\}/g, (_m, id) => `{/*${slugifyId(id)}*/}`); + + // Normalize all heading ids in comments everywhere. + s = s.replace(/\{\/\*([^*]+)\*\/\}/g, (_m, id) => `{/*${slugifyId(id)}*/}`); + + // In prose, raw html tag mentions should be inline-code, not actual HTML. + // Avoid touching real JSX/MDX component lines that start with < + const lines = s.split(/\r?\n/); + let inCode = false; + for (let i = 0; i < lines.length; i++) { + let line = lines[i]; + const t = line.trim(); + if (t.startsWith('```')) { + inCode = !inCode; + continue; + } + if (inCode) continue; + if (t.startsWith('<') || t.startsWith('/g, '`<$1>`') + .replace(/<\/(input|button|div|span|h1|h2|h3|p|li|ul|ol|section|nav|img)>/g, '``'); + + // Fix common broken quote pattern around inline tags after translation. + line = line.replace(/-`<(input|button)>`'/g, '-`<$1>`'); + line = line.replace(/-<(input|button)>'/g, '-`<$1>`'); + + // Avoid literal curly braces in prose that break MDX expressions. + if (/\*\*.*\{.*\*\*/.test(line) && !line.includes('`{`')) { + line = line.replace(/\{/g, '`{`').replace(/\}/g, '`}`'); + } + + lines[i] = line; + } + s = lines.join('\n'); + + // Targeted fix for known broken heading in reacting-to-input-with-state. + if (f === 'reacting-to-input-with-state.md') { + s = s.replace( + /^### .*set-state.*$/m, + '### שלב 5: חברו את מטפלי האירועים לעדכון מצב {/*step-5-connect-the-event-handlers-to-set-state*/}' + ); + } + + if (s !== original) { + fs.writeFileSync(p, s); + console.log('fixed', p); + } +} + +console.log('done'); diff --git a/scripts/translate-learn.mjs b/scripts/translate-learn.mjs new file mode 100644 index 000000000..30406aa4d --- /dev/null +++ b/scripts/translate-learn.mjs @@ -0,0 +1,113 @@ +import fs from 'fs'; +import path from 'path'; + +const dir = 'src/content/learn'; +const files = fs.readdirSync(dir).filter((f) => f.endsWith('.md')); + +const cachePath = 'scripts/.translate-cache-learn.json'; +const cache = new Map( + fs.existsSync(cachePath) + ? Object.entries(JSON.parse(fs.readFileSync(cachePath, 'utf8'))) + : [] +); +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); + +function hasEnglish(line) { + return /[A-Za-z]{2,}/.test(line); +} + +async function translateText(text) { + const input = text.trim(); + if (!input) return text; + if (cache.has(input)) return text.replace(input, cache.get(input)); + + const url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=he&dt=t&q=' + encodeURIComponent(input); + const res = await fetch(url, { + headers: { + 'User-Agent': 'Mozilla/5.0', + 'Accept': 'application/json,text/plain,*/*', + }, + }); + if (!res.ok) throw new Error('translate failed: ' + res.status); + const data = await res.json(); + const out = (data?.[0] || []).map((x) => x?.[0] || '').join(''); + cache.set(input, out || input); + await sleep(10); + return text.replace(input, out || input); +} + +for (const f of files) { + const p = path.join(dir, f); + const src = fs.readFileSync(p, 'utf8'); + const lines = src.split(/\r?\n/); + + let inCode = false; + let inFrontmatter = false; + let frontmatterSeen = false; + let changed = false; + + for (let i = 0; i < lines.length; i++) { + let line = lines[i]; + + if (line.trim() === '```' || line.trim().startsWith('```')) { + inCode = !inCode; + continue; + } + + if (!frontmatterSeen && line.trim() === '---') { + inFrontmatter = !inFrontmatter; + if (!inFrontmatter) frontmatterSeen = true; + continue; + } + + if (inCode) continue; + + // Frontmatter: translate title when contains English + if (inFrontmatter) { + const m = line.match(/^(title:\s*)(.+)$/); + if (m && hasEnglish(m[2])) { + const raw = m[2].trim(); + const unquoted = raw.replace(/^['\"]|['\"]$/g, ''); + const translated = await translateText(unquoted); + lines[i] = `${m[1]}${JSON.stringify(translated.trim())}`; + changed = true; + } + continue; + } + + const t = line.trim(); + if (!t) continue; + if (t.startsWith('<') || t.startsWith(' ')) { + // translate blockquotes too + } + + // avoid touching lines that are mostly syntax/code/table separators + if (/^\|?\s*[-:|`]+\s*$/.test(t)) continue; + if (t.includes('```')) continue; + + if (!hasEnglish(t)) continue; + + try { + const translatedLine = await translateText(line); + if (translatedLine !== line) { + lines[i] = translatedLine; + changed = true; + } + } catch (e) { + // keep going on per-line failure + } + } + + if (changed) { + fs.writeFileSync(p, lines.join('\n')); + console.log('updated', p); + } +} + +fs.writeFileSync( + cachePath, + JSON.stringify(Object.fromEntries(cache), null, 2) +); + +console.log('done'); diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index 26bdf6711..d014418d3 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -288,50 +288,46 @@ export function Footer() {
- Learn React - - Quick Start - Installation - - Describing the UI + לימוד React + התחלה מהירה + התקנה + תיאור ה-UI - Adding Interactivity + הוספת אינטראקטיביות - Managing State - Escape Hatches + ניהול State + דרכי מילוט
- API Reference + מדריך API React APIs React DOM APIs
- Community + קהילה - Code of Conduct + קוד התנהגות - Meet the Team + הכירו את הצוות - Docs Contributors - - - Acknowledgements + תורמי התיעוד + תודות
- More - Blog + עוד + בלוג React Native - Privacy + פרטיות - Terms + תנאים

- The library for web and native user interfaces + הספרייה לממשקי משתמש לווב ולנייטיב

- Learn React + label="לימוד React"> + לימוד React - API Reference + label="מדריך API"> + מדריך API
-
Create user interfaces from components
+
צרו ממשקי משתמש מקומפוננטות
- React lets you build user interfaces out of individual pieces - called components. Create your own React components like{' '} - Thumbnail, LikeButton, and{' '} - Video. Then combine them into entire screens, pages, - and apps. + React מאפשרת לכם לבנות ממשקי משתמש מחלקים נפרדים שנקראים + קומפוננטות. צרו קומפוננטות React משלכם כמו Thumbnail,{' '} + LikeButton ו-Video, ואז חברו אותן + למסכים, דפים ואפליקציות שלמים.
@@ -162,22 +161,20 @@ export function HomeContent() {
- Whether you work on your own or with thousands of other - developers, using React feels the same. It is designed to let you - seamlessly combine components written by independent people, - teams, and organizations. + בין אם אתם עובדים לבד או יחד עם אלפי מפתחים אחרים, העבודה עם React + מרגישה אותו דבר. היא תוכננה כך שתוכלו לשלב בצורה חלקה קומפוננטות + שנכתבו על ידי אנשים, צוותים וארגונים שונים.
-
Write components with code and markup
+
כתבו קומפוננטות עם קוד ו-Markup
- React components are JavaScript functions. Want to show some - content conditionally? Use an if statement. - Displaying a list? Try array map(). Learning React is - learning programming. + קומפוננטות React הן פונקציות JavaScript. רוצים להציג תוכן בצורה + מותנית? השתמשו במשפט if. רוצים להציג רשימה? נסו + להשתמש ב-map() על מערך. ללמוד React זה ללמוד תכנות.
@@ -185,22 +182,21 @@ export function HomeContent() {
- This markup syntax is called JSX. It is a JavaScript syntax - extension popularized by React. Putting JSX markup close to - related rendering logic makes React components easy to create, - maintain, and delete. + תחביר ה-Markup הזה נקרא JSX. זו הרחבת תחביר של JavaScript ש-React + הפכה לפופולרית. כשכותבים JSX קרוב ללוגיקת הרינדור הרלוונטית, + קומפוננטות React נעשות קלות יותר ליצירה, תחזוקה והסרה.
-
Add interactivity wherever you need it
+
הוסיפו אינטראקטיביות בכל מקום שצריך
- React components receive data and return what should appear on the - screen. You can pass them new data in response to an interaction, - like when the user types into an input. React will then update the - screen to match the new data. + קומפוננטות React מקבלות נתונים ומחזירות את מה שצריך להופיע על + המסך. אפשר להעביר להן נתונים חדשים בתגובה לאינטראקציה, למשל + כשהמשתמש מקליד בשדה קלט. אחר כך React מעדכנת את המסך כך שיתאים + לנתונים החדשים.
@@ -208,16 +204,15 @@ export function HomeContent() {
- You don’t have to build your whole page in React. Add React to - your existing HTML page, and render interactive React components - anywhere on it. + לא חייבים לבנות את כל הדף ב-React. אפשר להוסיף React לדף HTML + קיים, ולרנדר בו קומפוננטות React אינטראקטיביות בכל מקום.
- Add React to your page + הוסיפו React לעמוד שלכם
@@ -226,14 +221,14 @@ export function HomeContent() {
- Go full-stack
- with a framework + עברו ל-full-stack
+ עם פריימוורק
- React is a library. It lets you put components together, but it - doesn’t prescribe how to do routing and data fetching. To build an - entire app with React, we recommend a full-stack React framework - like Next.js or{' '} + React היא ספרייה. היא מאפשרת להרכיב קומפוננטות, אבל לא מכתיבה איך + לבצע ניתוב ושליפת נתונים. כדי לבנות אפליקציה שלמה עם React, אנחנו + ממליצים על פריימוורק React מלא כמו{' '} + Next.js או{' '} Remix.
@@ -242,17 +237,17 @@ export function HomeContent() {
- React is also an architecture. Frameworks that implement it let - you fetch data in asynchronous components that run on the server - or even during the build. Read data from a file or a database, and - pass it down to your interactive components. + React היא גם ארכיטקטורה. פריימוורקים שמממשים אותה מאפשרים שליפת + נתונים מתוך קומפוננטות אסינכרוניות שרצות בשרת או אפילו בזמן build. + אפשר לקרוא נתונים מקובץ או ממסד נתונים ולהעביר אותם לקומפוננטות + האינטראקטיביות שלכם.
- Get started with a framework + התחילו עם פריימוורק
@@ -260,12 +255,11 @@ export function HomeContent() {
-
Use the best from every platform
+
קחו את הטוב ביותר מכל פלטפורמה
- People love web and native apps for different reasons. React - lets you build both web apps and native apps using the same - skills. It leans upon each platform’s unique strengths to let - your interfaces feel just right on every platform. + אנשים אוהבים אפליקציות ווב ונייטיב מסיבות שונות. React מאפשרת + לבנות את שתיהן עם אותם כישורים. היא נשענת על החוזקות הייחודיות + של כל פלטפורמה כדי שממשקי המשתמש ירגישו נכון בכל מקום.
@@ -279,15 +273,14 @@ export function HomeContent() {

- Stay true to the web + נאמנים לווב

- People expect web app pages to load fast. On the server, - React lets you start streaming HTML while you’re still - fetching data, progressively filling in the remaining - content before any JavaScript code loads. On the client, - React can use standard web APIs to keep your UI - responsive even in the middle of rendering. + משתמשים מצפים שדפי ווב ייטענו מהר. בצד השרת, React + מאפשרת להתחיל להזרים HTML בזמן שעדיין שולפים נתונים, + ולמלא בהדרגה את שאר התוכן עוד לפני שקוד JavaScript נטען. + בצד הלקוח, React יכולה להשתמש ב-Web APIs סטנדרטיים כדי + לשמור על ממשק משתמש תגובתי גם באמצע רינדור.

@@ -365,21 +358,21 @@ export function HomeContent() {

- Go truly native + עברו לנייטיב אמיתי

- People expect native apps to look and feel like their - platform.{' '} + משתמשים מצפים שאפליקציות נייטיב ייראו וירגישו כמו + הפלטפורמה שלהן.{' '} React Native {' '} - and{' '} + ו-{' '} Expo{' '} - let you build apps in React for Android, iOS, and - more. They look and feel native because their UIs{' '} - are truly native. It’s not a web view—your - React components render real Android and iOS views - provided by the platform. + מאפשרות לבנות אפליקציות ב-React ל-Android, ל-iOS ולעוד + פלטפורמות. הן נראות ומרגישות נייטיב כי ה-UI שלהן + באמת נייטיב. זו לא תצוגת web view; קומפוננטות + React שלכם מרנדרות תצוגות אמיתיות של Android ו-iOS + שסופקו על ידי הפלטפורמה.

@@ -389,14 +382,14 @@ export function HomeContent() {
- With React, you can be a web and a native developer. Your - team can ship to many platforms without sacrificing the user - experience. Your organization can bridge the platform silos, and - form teams that own entire features end-to-end. + עם React אפשר להיות מפתחי ווב וגם נייטיב. הצוות שלכם יכול + לשלוח פיצ׳רים להרבה פלטפורמות בלי להתפשר על חוויית המשתמש. + הארגון שלכם יכול לגשר על הפערים בין פלטפורמות ולבנות צוותים + שלוקחים בעלות על יכולות מקצה לקצה.
- Build for native platforms + בנו לפלטפורמות נייטיב
@@ -407,23 +400,21 @@ export function HomeContent() {
-
Upgrade when the future is ready
+
שדרגו כשהעתיד מוכן
- React approaches changes with care. Every React commit is - tested on business-critical surfaces with over a billion - users. Over 100,000 React components at Meta help validate - every migration strategy. + React ניגשת לשינויים בזהירות. כל commit של React נבדק על + משטחים עסקיים קריטיים עם יותר ממיליארד משתמשים. מעל 100,000 + קומפוננטות React ב-Meta עוזרות לאמת כל אסטרטגיית מיגרציה.
- The React team is always researching how to improve React. - Some research takes years to pay off. React has a high bar - for taking a research idea into production. Only proven - approaches become a part of React. + צוות React תמיד חוקר איך לשפר את React. לפעמים לוקח שנים עד + שמחקר מבשיל. ל-React יש רף גבוה לפני שמעבירים רעיון מחקרי + לפרודקשן. רק גישות מוכחות הופכות לחלק מ-React.
- Read more React news + לקריאת חדשות React נוספות
@@ -431,7 +422,7 @@ export function HomeContent() {

- Latest React News + חדשות React האחרונות

@@ -449,7 +440,7 @@ export function HomeContent() {
- Read more React news + לקריאת חדשות React נוספות
@@ -462,13 +453,13 @@ export function HomeContent() {
- Join a community
- of millions + הצטרפו לקהילה
+ של מיליונים
- You’re not alone. Two million developers from all over the - world visit the React docs every month. React is something - that people and teams can agree on. + אתם לא לבד. שני מיליון מפתחים מכל העולם מבקרים בתיעוד של React + בכל חודש. React היא משהו שאנשים וצוותים יכולים להסכים עליו + יחד.
@@ -476,13 +467,11 @@ export function HomeContent() {
- This is why React is more than a library, an architecture, or - even an ecosystem. React is a community. It’s a place where - you can ask for help, find opportunities, and meet new - friends. You will meet both developers and designers, - beginners and experts, researchers and artists, teachers and - students. Our backgrounds may be very different, but React - lets us all create user interfaces together. + לכן React היא יותר מספרייה, ארכיטקטורה או אפילו אקו-סיסטם. + React היא קהילה. זה מקום שבו אפשר לבקש עזרה, למצוא הזדמנויות + ולהכיר חברים חדשים. תפגשו כאן מפתחים ומעצבים, מתחילים ומומחים, + חוקרים ואמנים, מורים ותלמידים. הרקע שלנו יכול להיות שונה מאוד, + אבל React מאפשרת לכולנו ליצור ממשקי משתמש יחד.
@@ -491,15 +480,12 @@ export function HomeContent() {
- Welcome to the
- React community + ברוכים הבאים ל- +
+ קהילת React
- - Get Started + + התחלה
@@ -651,35 +637,35 @@ const reactConf2019Cover = '/images/home/conf2019/cover.svg'; const communityImages = [ { src: '/images/home/community/react_conf_fun.webp', - alt: 'People singing karaoke at React Conf', + alt: 'אנשים שרים קריוקי ב-React Conf', }, { src: '/images/home/community/react_india_sunil.webp', - alt: 'Sunil Pai speaking at React India', + alt: 'Sunil Pai מרצה ב-React India', }, { src: '/images/home/community/react_conf_hallway.webp', - alt: 'A hallway conversation between two people at React Conf', + alt: 'שיחת מסדרון בין שני אנשים ב-React Conf', }, { src: '/images/home/community/react_india_hallway.webp', - alt: 'A hallway conversation at React India', + alt: 'שיחת מסדרון ב-React India', }, { src: '/images/home/community/react_conf_elizabet.webp', - alt: 'Elizabet Oliveira speaking at React Conf', + alt: 'Elizabet Oliveira מרצה ב-React Conf', }, { src: '/images/home/community/react_india_selfie.webp', - alt: 'People taking a group selfie at React India', + alt: 'אנשים מצלמים סלפי קבוצתי ב-React India', }, { src: '/images/home/community/react_conf_nat.webp', - alt: 'Nat Alison speaking at React Conf', + alt: 'Nat Alison מרצה ב-React Conf', }, { src: '/images/home/community/react_india_team.webp', - alt: 'Organizers greeting attendees at React India', + alt: 'מארגנים שמברכים את המשתתפים ב-React India', }, ]; @@ -915,8 +901,8 @@ function Example1() {
@@ -1084,10 +1070,10 @@ function SearchableVideoList({ videos }) { contentMarginTop="72px" height="30rem">

- React Videos + סרטוני React

- A brief history of React + היסטוריה קצרה של React

@@ -1335,7 +1321,7 @@ function ConferencePage({slug}) { const conf = use(fetchConf(slug)); return ( -
+
}> @@ -1408,7 +1394,7 @@ function SearchableVideoList({videos}) {
); @@ -1434,7 +1420,7 @@ function VideoList({videos, emptyHeading}) { let heading = emptyHeading; const count = videos.length; if (count > 0) { - const noun = count > 1 ? 'Videos' : 'Video'; + const noun = count > 1 ? 'סרטונים' : 'סרטון'; heading = count + ' ' + noun; } return ( @@ -1461,7 +1447,7 @@ function SearchInput({value, onChange}) { data-hover="SearchInput" onSubmit={(e) => e.preventDefault()}>
@@ -1471,7 +1457,7 @@ function SearchInput({value, onChange}) { type="text" id={id} className="flex ps-11 py-4 h-10 w-full text-start bg-secondary-button outline-none betterhover:hover:bg-opacity-80 pointer items-center text-primary rounded-full align-middle text-base" - placeholder="Search" + placeholder="חיפוש" value={value} onChange={(e) => onChange(e.target.value)} /> @@ -2390,8 +2376,8 @@ function fetchTalks(confId) { resolve([ { id: 'conf-2021-0', - title: 'React 18 Keynote', - description: 'The React Team', + title: 'הרצאת פתיחה: React 18', + description: 'צוות React', url: 'https://www.youtube.com/watch?v=FZ0cG47msEk&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=1', image: { speakers: [ @@ -2404,7 +2390,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-1', - title: 'React 18 for App Developers', + title: 'React 18 למפתחי אפליקציות', description: 'Shruti Kapoor', url: 'https://www.youtube.com/watch?v=ytudH8je5ko&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=2', image: { @@ -2413,7 +2399,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-2', - title: 'Streaming Server Rendering with Suspense', + title: 'רינדור שרת בסטרימינג עם Suspense', description: 'Shaundai Person', url: 'https://www.youtube.com/watch?v=pj5N-Khihgc&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=3', image: { @@ -2422,7 +2408,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-3', - title: 'The First React Working Group', + title: 'קבוצת העבודה הראשונה של React', description: 'Aakansha Doshi', url: 'https://www.youtube.com/watch?v=qn7gRClrC9U&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=4', image: { @@ -2431,7 +2417,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-4', - title: 'React Developer Tooling', + title: 'כלי פיתוח ל-React', description: 'Brian Vaughn', url: 'https://www.youtube.com/watch?v=oxDfrke8rZg&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=5', image: { @@ -2440,7 +2426,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-5', - title: 'React without memo', + title: 'React בלי memo', description: 'Xuan Huang (黄玄)', url: 'https://www.youtube.com/watch?v=lGEMwh32soc&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=6', image: { @@ -2449,7 +2435,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-6', - title: 'React Docs Keynote', + title: 'הרצאת תיעוד React', description: 'Rachel Nabors', url: 'https://www.youtube.com/watch?v=mneDaMYOKP8&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=7', image: { @@ -2458,7 +2444,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-7', - title: 'Things I Learnt from the New React Docs', + title: 'מה למדתי מהתיעוד החדש של React', description: "Debbie O'Brien", url: 'https://www.youtube.com/watch?v=-7odLW_hG7s&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=8', image: { @@ -2467,7 +2453,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-8', - title: 'Learning in the Browser', + title: 'למידה בדפדפן', description: 'Sarah Rainsberger', url: 'https://www.youtube.com/watch?v=5X-WEQflCL0&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=9', image: { @@ -2476,7 +2462,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-9', - title: 'The ROI of Designing with React', + title: 'ה-ROI של עיצוב עם React', description: 'Linton Ye', url: 'https://www.youtube.com/watch?v=7cPWmID5XAk&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=10', image: { @@ -2485,7 +2471,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-10', - title: 'Interactive Playgrounds with React', + title: 'Playgrounds אינטראקטיביים עם React', description: 'Delba de Oliveira', url: 'https://www.youtube.com/watch?v=zL8cz2W0z34&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=11', image: { @@ -2494,7 +2480,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-11', - title: 'Re-introducing Relay', + title: 'הצגה מחדש של Relay', description: 'Robert Balicki', url: 'https://www.youtube.com/watch?v=lhVGdErZuN4&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=12', image: { @@ -2503,7 +2489,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-12', - title: 'React Native Desktop', + title: 'React Native למחשבים שולחניים', description: 'Eric Rozell and Steven Moyes', url: 'https://www.youtube.com/watch?v=9L4FFrvwJwY&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=13', image: { @@ -2515,7 +2501,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-13', - title: 'On-device Machine Learning for React Native', + title: 'למידת מכונה על המכשיר עבור React Native', description: 'Roman Rädle', url: 'https://www.youtube.com/watch?v=NLj73vrc2I8&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=14', image: { @@ -2524,7 +2510,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-14', - title: 'React 18 for External Store Libraries', + title: 'React 18 לספריות External Store', description: 'Daishi Kato', url: 'https://www.youtube.com/watch?v=oPfSC5bQPR8&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=15', image: { @@ -2533,7 +2519,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-15', - title: 'Building Accessible Components with React 18', + title: 'בניית קומפוננטות נגישות עם React 18', description: 'Diego Haz', url: 'https://www.youtube.com/watch?v=dcm8fjBfro8&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=16', image: { @@ -2542,7 +2528,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-16', - title: 'Accessible Japanese Form Components with React', + title: 'קומפוננטות טפסים יפניות נגישות עם React', description: 'Tafu Nakazaki', url: 'https://www.youtube.com/watch?v=S4a0QlsH0pU&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=17', image: { @@ -2551,7 +2537,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-17', - title: 'UI Tools for Artists', + title: 'כלי UI לאמנים', description: 'Lyle Troxell', url: 'https://www.youtube.com/watch?v=b3l4WxipFsE&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=18', image: { @@ -2560,7 +2546,7 @@ function fetchTalks(confId) { }, { id: 'conf-2021-18', - title: 'Hydrogen + React 18', + title: 'Hydrogen ו-React 18', description: 'Helen Lin', url: 'https://www.youtube.com/watch?v=HS6vIYkSNks&list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&index=19', image: { @@ -2572,7 +2558,7 @@ function fetchTalks(confId) { resolve([ { id: 'conf-2019-0', - title: 'Keynote (Part 1)', + title: 'הרצאת פתיחה (חלק 1)', description: 'Tom Occhino', url: 'https://www.youtube.com/watch?v=QnZHO7QvjaM&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh', image: { @@ -2581,7 +2567,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-1', - title: 'Keynote (Part 2)', + title: 'הרצאת פתיחה (חלק 2)', description: 'Yuzhi Zheng', url: 'https://www.youtube.com/watch?v=uXEEL9mrkAQ&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=2', image: { @@ -2590,7 +2576,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-2', - title: 'Building The New Facebook With React and Relay (Part 1)', + title: 'בניית פייסבוק החדשה עם React ו-Relay (חלק 1)', description: 'Frank Yan', url: 'https://www.youtube.com/watch?v=9JZHodNR184&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=3', image: { @@ -2599,7 +2585,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-3', - title: 'Building The New Facebook With React and Relay (Part 2)', + title: 'בניית פייסבוק החדשה עם React ו-Relay (חלק 2)', description: 'Ashley Watkins', url: 'https://www.youtube.com/watch?v=KT3XKDBZW7M&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=4', image: { @@ -2608,7 +2594,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-4', - title: 'How Our Team Is Using React Native to Save The World', + title: 'איך הצוות שלנו משתמש ב-React Native כדי להציל את העולם', description: 'Tania Papazafeiropoulou', url: 'https://www.youtube.com/watch?v=zVHWugBPGBE&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=5', image: { @@ -2618,7 +2604,7 @@ function fetchTalks(confId) { { id: 'conf-2019-5', title: - 'Using Hooks and Codegen to Bring the Benefits of GraphQL to REST APIs', + 'שימוש ב-Hooks וב-Codegen כדי להביא את היתרונות של GraphQL אל REST APIs', description: 'Tejas Kumar', url: 'https://www.youtube.com/watch?v=cdsnzfJUqm0&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=6', image: { @@ -2627,7 +2613,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-6', - title: 'Building a Custom React Renderer', + title: 'בניית React Renderer מותאם אישית', description: 'Sophie Alpert', url: 'https://www.youtube.com/watch?v=CGpMlWVcHok&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=7', image: { @@ -2636,7 +2622,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-7', - title: 'Is React Translated Yet?', + title: 'האם React כבר מתורגמת?', description: 'Nat Alison', url: 'https://www.youtube.com/watch?v=lLE4Jqaek5k&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=12', image: { @@ -2645,7 +2631,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-8', - title: 'Building (And Re-Building) the Airbnb Design System', + title: 'בניית (ובנייה מחדש של) מערכת העיצוב של Airbnb', description: 'Maja Wichrowska and Tae Kim', url: 'https://www.youtube.com/watch?v=fHQ1WSx41CA&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=13', image: { @@ -2657,7 +2643,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-9', - title: 'Accessibility Is a Marathon, Not a Sprint', + title: 'נגישות היא מרתון, לא ספרינט', description: 'Brittany Feenstra', url: 'https://www.youtube.com/watch?v=ONSD-t4gBb8&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=14', image: { @@ -2666,7 +2652,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-10', - title: 'The State of React State in 2019', + title: 'מצב ה-State ב-React בשנת 2019', description: 'Becca Bailey', url: 'https://www.youtube.com/watch?v=wUMMUyQtMSg&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=15', image: { @@ -2675,7 +2661,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-11', - title: 'Let’s Program Like It’s 1999', + title: 'בואו נתכנת כאילו זו 1999', description: 'Lee Byron', url: 'https://www.youtube.com/watch?v=vG8WpLr6y_U&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=16', image: { @@ -2684,7 +2670,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-12', - title: 'React Developer Tooling', + title: 'כלי פיתוח ל-React', description: 'Brian Vaughn', url: 'https://www.youtube.com/watch?v=Mjrfb1r3XEM&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=17', image: { @@ -2693,7 +2679,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-13', - title: 'Data Fetching With Suspense In Relay', + title: 'שליפת נתונים עם Suspense ב-Relay', description: 'Joe Savona', url: 'https://www.youtube.com/watch?v=Tl0S7QkxFE4&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=18', image: { @@ -2702,7 +2688,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-14', - title: 'Automatic Visualizations of the Frontend', + title: 'ויזואליזציות אוטומטיות של ה-Frontend', description: 'Cameron Yick', url: 'https://www.youtube.com/watch?v=SbreAPNmZOk&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=19', image: { @@ -2711,7 +2697,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-15', - title: 'React Is Fiction', + title: 'React היא בדיון', description: 'Jenn Creighton', url: 'https://www.youtube.com/watch?v=kqh4lz2Lkzs&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=20', image: { @@ -2720,7 +2706,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-16', - title: 'Progressive Web Animations', + title: 'אנימציות ווב פרוגרסיביות', description: 'Alexandra Holachek', url: 'https://www.youtube.com/watch?v=laPsceJ4tTY&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=21', image: { @@ -2729,8 +2715,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-17', - title: - 'Creating Games, Animations and Interactions with the Wick Editor', + title: 'יצירת משחקים, אנימציות ואינטראקציות עם Wick Editor', description: 'Luca Damasco', url: 'https://www.youtube.com/watch?v=laPsceJ4tTY&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=21', image: { @@ -2739,7 +2724,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-18', - title: 'Building React-Select', + title: 'בניית React-Select', description: 'Jed Watson', url: 'https://www.youtube.com/watch?v=yS0jUnmBujE&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=25', image: { @@ -2748,7 +2733,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-19', - title: 'Promoting Transparency in Government Spending with React', + title: 'קידום שקיפות בהוצאות ממשלתיות עם React', description: 'Lizzie Salita', url: 'https://www.youtube.com/watch?v=CVfXICcNfHE&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=26', image: { @@ -2757,7 +2742,7 @@ function fetchTalks(confId) { }, { id: 'conf-2019-20', - title: 'Wonder-driven Development: Using React to Make a Spaceship', + title: 'פיתוח מונחה סקרנות: שימוש ב-React כדי לבנות חללית', description: 'Alex Anderson', url: 'https://www.youtube.com/watch?v=aV0uOPWHKt4&list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh&index=27', image: { diff --git a/src/components/Layout/TopNav/TopNav.tsx b/src/components/Layout/TopNav/TopNav.tsx index b6e276ff7..ea41cacae 100644 --- a/src/components/Layout/TopNav/TopNav.tsx +++ b/src/components/Layout/TopNav/TopNav.tsx @@ -110,7 +110,7 @@ function NavItem({url, isActive, children}: any) { ; } @@ -167,11 +167,11 @@ function Form() { -### Read the form data being submitted {/*read-form-data-being-submitted*/} +### קריאת נתוני הטופס שנשלחים {/*read-form-data-being-submitted*/} -You can use the `data` property of the status information returned from `useFormStatus` to display what data is being submitted by the user. +אפשר להשתמש במאפיין `data` מתוך מידע הסטטוס שמוחזר מ-`useFormStatus` כדי להציג אילו נתונים המשתמש שולח. -Here, we have a form where users can request a username. We can use `useFormStatus` to display a temporary status message confirming what username they have requested. +כאן יש לנו טופס שבו משתמשים יכולים לבקש שם משתמש. אפשר להשתמש ב-`useFormStatus` כדי להציג הודעת סטטוס זמנית שמאשרת איזה שם משתמש הם ביקשו. @@ -245,16 +245,16 @@ button { "devDependencies": {} } ``` - + --- -## Troubleshooting {/*troubleshooting*/} +## פתרון תקלות {/*troubleshooting*/} -### `status.pending` is never `true` {/*pending-is-never-true*/} +### `status.pending` אף פעם לא `true` {/*pending-is-never-true*/} -`useFormStatus` will only return status information for a parent ``. +`useFormStatus` תחזיר מידע סטטוס רק עבור `` הורה. -If the component that calls `useFormStatus` is not nested in a ``, `status.pending` will always return `false`. Verify `useFormStatus` is called in a component that is a child of a `` element. +אם הקומפוננטה שקוראת ל-`useFormStatus` אינה מקוננת בתוך ``, הערך `status.pending` תמיד יהיה `false`. ודאו ש-`useFormStatus` נקראת בתוך קומפוננטה שהיא child של אלמנט ``. -`useFormStatus` will not track the status of a `` rendered in the same component. See [Pitfall](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) for more details. +`useFormStatus` לא תעקוב אחרי הסטטוס של `` שמרונדרת באותה קומפוננטה. ראו [Pitfall](#useformstatus-will-not-return-status-information-for-a-form-rendered-in-the-same-component) לפרטים נוספים. diff --git a/src/content/reference/react-dom/hydrate.md b/src/content/reference/react-dom/hydrate.md index 0d1e1cdf9..a3dbc5711 100644 --- a/src/content/reference/react-dom/hydrate.md +++ b/src/content/reference/react-dom/hydrate.md @@ -4,15 +4,15 @@ title: hydrate -This API will be removed in a future major version of React. +ה-API הזה יוסר בגרסה ראשית עתידית של React. -In React 18, `hydrate` was replaced by [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot) Using `hydrate` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis) +ב-React 18, `hydrate` הוחלפה ב-[`hydrateRoot`.](/reference/react-dom/client/hydrateRoot) שימוש ב-`hydrate` ב-React 18 יציג אזהרה שהאפליקציה שלכם תתנהג כאילו היא רצה על React 17. מידע נוסף [כאן.](/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis) -`hydrate` lets you display React components inside a browser DOM node whose HTML content was previously generated by [`react-dom/server`](/reference/react-dom/server) in React 17 and below. +`hydrate` מאפשרת להציג קומפוננטות React בתוך DOM node של דפדפן, כשהתוכן ה-HTML שלו נוצר קודם על ידי [`react-dom/server`](/reference/react-dom/server) ב-React 17 ומטה. ```js hydrate(reactNode, domNode, callback?) @@ -28,7 +28,7 @@ hydrate(reactNode, domNode, callback?) ### `hydrate(reactNode, domNode, callback?)` {/*hydrate*/} -Call `hydrate` in React 17 and below to “attach” React to existing HTML that was already rendered by React in a server environment. +ב-React 17 ומטה, קראו ל-`hydrate` כדי "לחבר" את React ל-HTML קיים שכבר רונדר על ידי React בסביבת שרת. ```js import { hydrate } from 'react-dom'; @@ -36,33 +36,33 @@ import { hydrate } from 'react-dom'; hydrate(reactNode, domNode); ``` -React will attach to the HTML that exists inside the `domNode`, and take over managing the DOM inside it. An app fully built with React will usually only have one `hydrate` call with its root component. +React תתחבר ל-HTML שקיים בתוך `domNode`, ותיקח שליטה על ניהול ה-DOM שבתוכו. אפליקציה שבנויה לגמרי ב-React תכלול בדרך כלל קריאת `hydrate` אחת בלבד עם קומפוננטת השורש שלה. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `reactNode`: The "React node" used to render the existing HTML. This will usually be a piece of JSX like `` which was rendered with a `ReactDOM Server` method such as `renderToString()` in React 17. +* `reactNode`: ‏"React node" ששימש לרינדור ה-HTML הקיים. בדרך כלל זו חתיכת JSX כמו `` שרונדרה עם מתודת `ReactDOM Server` כמו `renderToString()` ב-React 17. -* `domNode`: A [DOM element](https://developer.mozilla.org/en-US/docs/Web/API/Element) that was rendered as the root element on the server. +* `domNode`: [אלמנט DOM](https://developer.mozilla.org/en-US/docs/Web/API/Element) שרונדר כ-root element בשרת. -* **optional**: `callback`: A function. If passed, React will call it after your component is hydrated. +* **אופציונלי**: `callback`: פונקציה. אם הועברה, React תקרא לה אחרי שהקומפוננטה עוברת hydration. #### Returns {/*returns*/} -`hydrate` returns null. +`hydrate` מחזירה null. #### Caveats {/*caveats*/} -* `hydrate` expects the rendered content to be identical with the server-rendered content. React can patch up differences in text content, but you should treat mismatches as bugs and fix them. -* In development mode, React warns about mismatches during hydration. There are no guarantees that attribute differences will be patched up in case of mismatches. This is important for performance reasons because in most apps, mismatches are rare, and so validating all markup would be prohibitively expensive. -* You'll likely have only one `hydrate` call in your app. If you use a framework, it might do this call for you. -* If your app is client-rendered with no HTML rendered already, using `hydrate()` is not supported. Use [render()](/reference/react-dom/render) (for React 17 and below) or [createRoot()](/reference/react-dom/client/createRoot) (for React 18+) instead. +* `hydrate` מצפה שהתוכן המרונדר יהיה זהה לתוכן שרונדר בשרת. React יכולה לתקן הבדלים בתוכן טקסט, אבל צריך להתייחס לחוסר התאמות כבאגים ולתקן אותם. +* במצב פיתוח, React מציגה אזהרות על חוסר התאמות בזמן hydration. אין הבטחה שהבדלי attributes יתוקנו במקרה של חוסר התאמה. זה חשוב מבחינת ביצועים כי ברוב האפליקציות חוסר התאמות נדיר, ולכן אימות מלא של כל ה-markup יהיה יקר מדי. +* סביר שתהיה לכם רק קריאת `hydrate` אחת באפליקציה. אם אתם משתמשים ב-framework, ייתכן שהוא יבצע את הקריאה הזו בשבילכם. +* אם האפליקציה שלכם מרונדרת בלקוח בלבד בלי HTML קיים, שימוש ב-`hydrate()` לא נתמך. השתמשו ב-[render()](/reference/react-dom/render) (עבור React 17 ומטה) או ב-[createRoot()](/reference/react-dom/client/createRoot) (עבור React 18+) במקום. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -Call `hydrate` to attach a React component into a server-rendered browser DOM node. +קראו ל-`hydrate` כדי לחבר קומפוננטת React לתוך DOM node של דפדפן שרונדר בשרת. ```js [[1, 3, ""], [2, 3, "document.getElementById('root')"]] import { hydrate } from 'react-dom'; @@ -70,13 +70,13 @@ import { hydrate } from 'react-dom'; hydrate(, document.getElementById('root')); ``` -Using `hydrate()` to render a client-only app (an app without server-rendered HTML) is not supported. Use [`render()`](/reference/react-dom/render) (in React 17 and below) or [`createRoot()`](/reference/react-dom/client/createRoot) (in React 18+) instead. +שימוש ב-`hydrate()` לרינדור אפליקציית לקוח בלבד (אפליקציה ללא HTML מרונדר שרת) לא נתמך. השתמשו ב-[`render()`](/reference/react-dom/render) (ב-React 17 ומטה) או ב-[`createRoot()`](/reference/react-dom/client/createRoot) (ב-React 18+) במקום. -### Hydrating server-rendered HTML {/*hydrating-server-rendered-html*/} +### ביצוע hydration ל-HTML מרונדר שרת {/*hydrating-server-rendered-html*/} -In React, "hydration" is how React "attaches" to existing HTML that was already rendered by React in a server environment. During hydration, React will attempt to attach event listeners to the existing markup and take over rendering the app on the client. +ב-React, "hydration" הוא האופן שבו React "מתחברת" ל-HTML קיים שכבר רונדר על ידי React בסביבת שרת. בזמן hydration, React תנסה לחבר event listeners ל-markup הקיים ולקחת שליטה על רינדור האפליקציה בצד הלקוח. -In apps fully built with React, **you will usually only hydrate one "root", once at startup for your entire app**. +באפליקציות שבנויות לגמרי עם React, **בדרך כלל תבצעו hydration רק ל"root" אחד, פעם אחת בזמן ההפעלה לכל האפליקציה**. @@ -104,17 +104,17 @@ export default function App() { -Usually you shouldn't need to call `hydrate` again or to call it in more places. From this point on, React will be managing the DOM of your application. To update the UI, your components will [use state.](/reference/react/useState) +בדרך כלל לא צריך לקרוא ל-`hydrate` שוב או במקומות נוספים. מהנקודה הזו React תנהל את ה-DOM של האפליקציה. כדי לעדכן את ה-UI, הקומפוננטות שלכם [ישתמשו ב-state.](/reference/react/useState) -For more information on hydration, see the docs for [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot) +למידע נוסף על hydration, ראו את התיעוד של [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot) --- -### Suppressing unavoidable hydration mismatch errors {/*suppressing-unavoidable-hydration-mismatch-errors*/} +### השתקת אזהרות hydration mismatch בלתי נמנעות {/*suppressing-unavoidable-hydration-mismatch-errors*/} -If a single element’s attribute or text content is unavoidably different between the server and the client (for example, a timestamp), you may silence the hydration mismatch warning. +אם attribute של אלמנט בודד או תוכן טקסט שלו שונים בהכרח בין השרת ללקוח (למשל timestamp), אפשר להשתיק את אזהרת ה-hydration mismatch. -To silence hydration warnings on an element, add `suppressHydrationWarning={true}`: +כדי להשתיק אזהרות hydration על אלמנט, הוסיפו `suppressHydrationWarning={true}`: @@ -146,13 +146,13 @@ export default function App() { -This only works one level deep, and is intended to be an escape hatch. Don’t overuse it. Unless it’s text content, React still won’t attempt to patch it up, so it may remain inconsistent until future updates. +זה עובד לעומק של רמה אחת בלבד, ומיועד כ-escape hatch. אל תשתמשו בזה מעבר לנדרש. אלא אם מדובר בתוכן טקסט, React עדיין לא תנסה לתקן אותו, ולכן הוא עלול להישאר לא עקבי עד עדכונים עתידיים. --- -### Handling different client and server content {/*handling-different-client-and-server-content*/} +### טיפול בתוכן שונה בין לקוח לשרת {/*handling-different-client-and-server-content*/} -If you intentionally need to render something different on the server and the client, you can do a two-pass rendering. Components that render something different on the client can read a [state variable](/reference/react/useState) like `isClient`, which you can set to `true` in an [effect](/reference/react/useEffect): +אם אתם צריכים בכוונה לרנדר משהו שונה בשרת ובלקוח, אפשר לבצע רינדור בשני מעברים. קומפוננטות שמרנדרות משהו שונה בלקוח יכולות לקרוא [משתנה state](/reference/react/useState) כמו `isClient`, שאפשר לקבוע ל-`true` בתוך [effect](/reference/react/useEffect): @@ -192,10 +192,10 @@ export default function App() { -This way the initial render pass will render the same content as the server, avoiding mismatches, but an additional pass will happen synchronously right after hydration. +כך מעבר הרינדור הראשוני ירנדר את אותו תוכן כמו בשרת וימנע חוסר התאמות, אבל מעבר נוסף יתרחש באופן סינכרוני מיד אחרי hydration. -This approach makes hydration slower because your components have to render twice. Be mindful of the user experience on slow connections. The JavaScript code may load significantly later than the initial HTML render, so rendering a different UI immediately after hydration may feel jarring to the user. +הגישה הזו הופכת hydration לאיטית יותר כי הקומפוננטות צריכות לרנדר פעמיים. שימו לב לחוויית המשתמש בחיבורים איטיים. קוד JavaScript עלול להיטען הרבה אחרי רינדור ה-HTML הראשוני, ולכן רינדור UI שונה מיד אחרי hydration עלול להרגיש קופצני למשתמש. diff --git a/src/content/reference/react-dom/index.md b/src/content/reference/react-dom/index.md index 80fd58fac..ea620e212 100644 --- a/src/content/reference/react-dom/index.md +++ b/src/content/reference/react-dom/index.md @@ -4,7 +4,7 @@ title: React DOM APIs -The `react-dom` package contains methods that are only supported for the web applications (which run in the browser DOM environment). They are not supported for React Native. +החבילה `react-dom` כוללת מתודות שנתמכות רק באפליקציות ווב (שפועלות בסביבת DOM של הדפדפן). הן לא נתמכות ב-React Native. @@ -12,45 +12,44 @@ The `react-dom` package contains methods that are only supported for the web app ## APIs {/*apis*/} -These APIs can be imported from your components. They are rarely used: +את ה-APIs האלה אפשר לייבא מתוך הקומפוננטות. הם בשימוש נדיר: -* [`createPortal`](/reference/react-dom/createPortal) lets you render child components in a different part of the DOM tree. -* [`flushSync`](/reference/react-dom/flushSync) lets you force React to flush a state update and update the DOM synchronously. +* [`createPortal`](/reference/react-dom/createPortal) מאפשר לרנדר קומפוננטות ילדים בחלק אחר של עץ ה-DOM. +* [`flushSync`](/reference/react-dom/flushSync) מאפשר לאלץ את React לבצע flush לעדכון state ולעדכן את ה-DOM בצורה סינכרונית. -## Resource Preloading APIs {/*resource-preloading-apis*/} +## APIs לטעינה מוקדמת של משאבים {/*resource-preloading-apis*/} -These APIs can be used to make apps faster by pre-loading resources such as scripts, stylesheets, and fonts as soon as you know you need them, for example before navigating to another page where the resources will be used. +אפשר להשתמש ב-APIs האלה כדי להאיץ אפליקציות באמצעות טעינה מוקדמת של משאבים כמו סקריפטים, קובצי סגנון וגופנים, מיד כשידוע שתצטרכו אותם, למשל לפני ניווט לעמוד אחר שבו המשאבים האלה יידרשו. -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call these APIs yourself. Consult your framework's documentation for details. +[Frameworks מבוססי React](/learn/start-a-new-react-project) מטפלים לעיתים קרובות בטעינת משאבים בשבילכם, אז ייתכן שלא תצטרכו לקרוא ל-APIs האלה ישירות. לפרטים, עיינו בתיעוד של ה-framework שלכם. -* [`prefetchDNS`](/reference/react-dom/prefetchDNS) lets you prefetch the IP address of a DNS domain name that you expect to connect to. -* [`preconnect`](/reference/react-dom/preconnect) lets you connect to a server you expect to request resources from, even if you don't know what resources you'll need yet. -* [`preload`](/reference/react-dom/preload) lets you fetch a stylesheet, font, image, or external script that you expect to use. -* [`preloadModule`](/reference/react-dom/preloadModule) lets you fetch an ESM module that you expect to use. -* [`preinit`](/reference/react-dom/preinit) lets you fetch and evaluate an external script or fetch and insert a stylesheet. -* [`preinitModule`](/reference/react-dom/preinitModule) lets you fetch and evaluate an ESM module. +* [`prefetchDNS`](/reference/react-dom/prefetchDNS) מאפשר לבצע prefetch לכתובת ה-IP של שם דומיין DNS שאתם מצפים להתחבר אליו. +* [`preconnect`](/reference/react-dom/preconnect) מאפשר להתחבר מראש לשרת שממנו אתם מצפים לבקש משאבים, גם אם עדיין לא ידוע אילו משאבים תצטרכו. +* [`preload`](/reference/react-dom/preload) מאפשר להביא מראש stylesheet, font, image, או סקריפט חיצוני שאתם מצפים להשתמש בהם. +* [`preloadModule`](/reference/react-dom/preloadModule) מאפשר להביא מראש מודול ESM שאתם מצפים להשתמש בו. +* [`preinit`](/reference/react-dom/preinit) מאפשר להביא ולהעריך סקריפט חיצוני, או להביא ולהכניס stylesheet. +* [`preinitModule`](/reference/react-dom/preinitModule) מאפשר להביא ולהעריך מודול ESM. --- -## Entry points {/*entry-points*/} +## נקודות כניסה {/*entry-points*/} -The `react-dom` package provides two additional entry points: +החבילה `react-dom` מספקת שתי נקודות כניסה נוספות: -* [`react-dom/client`](/reference/react-dom/client) contains APIs to render React components on the client (in the browser). -* [`react-dom/server`](/reference/react-dom/server) contains APIs to render React components on the server. +* [`react-dom/client`](/reference/react-dom/client) כוללת APIs לרינדור קומפוננטות React בצד לקוח (בדפדפן). +* [`react-dom/server`](/reference/react-dom/server) כוללת APIs לרינדור קומפוננטות React בצד שרת. --- -## Deprecated APIs {/*deprecated-apis*/} +## APIs שהוצאו משימוש {/*deprecated-apis*/} -These APIs will be removed in a future major version of React. +ה-APIs האלה יוסרו בגרסה ראשית עתידית של React. -* [`findDOMNode`](/reference/react-dom/findDOMNode) finds the closest DOM node corresponding to a class component instance. -* [`hydrate`](/reference/react-dom/hydrate) mounts a tree into the DOM created from server HTML. Deprecated in favor of [`hydrateRoot`](/reference/react-dom/client/hydrateRoot). -* [`render`](/reference/react-dom/render) mounts a tree into the DOM. Deprecated in favor of [`createRoot`](/reference/react-dom/client/createRoot). -* [`unmountComponentAtNode`](/reference/react-dom/unmountComponentAtNode) unmounts a tree from the DOM. Deprecated in favor of [`root.unmount()`](/reference/react-dom/client/createRoot#root-unmount). - +* [`findDOMNode`](/reference/react-dom/findDOMNode) מוצא את DOM node הקרוב ביותר שמקביל למופע class component. +* [`hydrate`](/reference/react-dom/hydrate) מרכיב עץ לתוך DOM שנוצר מ-HTML של שרת. הוצא משימוש לטובת [`hydrateRoot`](/reference/react-dom/client/hydrateRoot). +* [`render`](/reference/react-dom/render) מרכיב עץ לתוך ה-DOM. הוצא משימוש לטובת [`createRoot`](/reference/react-dom/client/createRoot). +* [`unmountComponentAtNode`](/reference/react-dom/unmountComponentAtNode) מסיר עץ מה-DOM. הוצא משימוש לטובת [`root.unmount()`](/reference/react-dom/client/createRoot#root-unmount). diff --git a/src/content/reference/react-dom/preconnect.md b/src/content/reference/react-dom/preconnect.md index cb14a5e89..1f036b549 100644 --- a/src/content/reference/react-dom/preconnect.md +++ b/src/content/reference/react-dom/preconnect.md @@ -5,13 +5,13 @@ canary: true -The `preconnect` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `preconnect` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -`preconnect` lets you eagerly connect to a server that you expect to load resources from. +`preconnect` מאפשרת להתחבר מראש לשרת שאתם מצפים לטעון ממנו משאבים. ```js preconnect("https://example.com"); @@ -27,7 +27,7 @@ preconnect("https://example.com"); ### `preconnect(href)` {/*preconnect*/} -To preconnect to a host, call the `preconnect` function from `react-dom`. +כדי לבצע preconnect ל-host, קראו לפונקציה `preconnect` מתוך `react-dom`. ```js import { preconnect } from 'react-dom'; @@ -39,34 +39,34 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The `preconnect` function provides the browser with a hint that it should open a connection to the given server. If the browser chooses to do so, this can speed up the loading of resources from that server. +הפונקציה `preconnect` מספקת לדפדפן רמז שכדאי לפתוח חיבור לשרת הנתון. אם הדפדפן בוחר לעשות זאת, זה יכול להאיץ טעינה של משאבים מהשרת הזה. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the server you want to connect to. +* `href`: מחרוזת. ה-URL של השרת שאליו רוצים להתחבר. #### Returns {/*returns*/} -`preconnect` returns nothing. +`preconnect` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple calls to `preconnect` with the same server have the same effect as a single call. -* In the browser, you can call `preconnect` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preconnect` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. -* If you know the specific resources you'll need, you can call [other functions](/reference/react-dom/#resource-preloading-apis) instead that will start loading the resources right away. -* There is no benefit to preconnecting to the same server the webpage itself is hosted from because it's already been connected to by the time the hint would be given. +* כמה קריאות ל-`preconnect` עם אותו שרת משפיעות כמו קריאה אחת. +* בדפדפן אפשר לקרוא ל-`preconnect` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`preconnect` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. +* אם אתם יודעים אילו משאבים ספציפיים תצטרכו, אפשר לקרוא [לפונקציות אחרות](/reference/react-dom/#resource-preloading-apis) שמתחילות לטעון את המשאבים מיד. +* אין תועלת ב-preconnect לאותו שרת שעליו מתארח דף הווב עצמו, כי החיבור אליו כבר פתוח עד לרגע שבו היה ניתן הרמז. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Preconnecting when rendering {/*preconnecting-when-rendering*/} +### Preconnect בזמן רינדור {/*preconnecting-when-rendering*/} -Call `preconnect` when rendering a component if you know that its children will load external resources from that host. +קראו ל-`preconnect` בזמן רינדור קומפוננטה אם אתם יודעים שהילדים שלה יטענו משאבים חיצוניים מאותו host. ```js import { preconnect } from 'react-dom'; @@ -77,9 +77,9 @@ function AppRoot() { } ``` -### Preconnecting in an event handler {/*preconnecting-in-an-event-handler*/} +### Preconnect בתוך event handler {/*preconnecting-in-an-event-handler*/} -Call `preconnect` in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`preconnect` בתוך event handler לפני מעבר לעמוד או מצב שבהם יידרשו משאבים חיצוניים. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { preconnect } from 'react-dom'; diff --git a/src/content/reference/react-dom/prefetchDNS.md b/src/content/reference/react-dom/prefetchDNS.md index f9889836e..fa8c88e92 100644 --- a/src/content/reference/react-dom/prefetchDNS.md +++ b/src/content/reference/react-dom/prefetchDNS.md @@ -5,13 +5,13 @@ canary: true -The `prefetchDNS` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `prefetchDNS` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -`prefetchDNS` lets you eagerly look up the IP of a server that you expect to load resources from. +`prefetchDNS` מאפשרת לבצע חיפוש מוקדם של כתובת ה-IP של שרת שאתם מצפים לטעון ממנו משאבים. ```js prefetchDNS("https://example.com"); @@ -27,7 +27,7 @@ prefetchDNS("https://example.com"); ### `prefetchDNS(href)` {/*prefetchdns*/} -To look up a host, call the `prefetchDNS` function from `react-dom`. +כדי לבצע lookup ל-host, קראו לפונקציה `prefetchDNS` מתוך `react-dom`. ```js import { prefetchDNS } from 'react-dom'; @@ -39,34 +39,34 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The prefetchDNS function provides the browser with a hint that it should look up the IP address of a given server. If the browser chooses to do so, this can speed up the loading of resources from that server. +הפונקציה `prefetchDNS` מספקת לדפדפן רמז שכדאי לו לבצע lookup לכתובת ה-IP של שרת נתון. אם הדפדפן בוחר לעשות זאת, זה יכול להאיץ טעינה של משאבים מהשרת הזה. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the server you want to connect to. +* `href`: מחרוזת. ה-URL של השרת שאליו רוצים להתחבר. #### Returns {/*returns*/} -`prefetchDNS` returns nothing. +`prefetchDNS` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple calls to `prefetchDNS` with the same server have the same effect as a single call. -* In the browser, you can call `prefetchDNS` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `prefetchDNS` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. -* If you know the specific resources you'll need, you can call [other functions](/reference/react-dom/#resource-preloading-apis) instead that will start loading the resources right away. -* There is no benefit to prefetching the same server the webpage itself is hosted from because it's already been looked up by the time the hint would be given. -* Compared with [`preconnect`](/reference/react-dom/preconnect), `prefetchDNS` may be better if you are speculatively connecting to a large number of domains, in which case the overhead of preconnections might outweigh the benefit. +* כמה קריאות ל-`prefetchDNS` עם אותו שרת משפיעות כמו קריאה אחת. +* בדפדפן אפשר לקרוא ל-`prefetchDNS` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`prefetchDNS` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. +* אם אתם יודעים אילו משאבים ספציפיים תצטרכו, אפשר לקרוא [לפונקציות אחרות](/reference/react-dom/#resource-preloading-apis) שמתחילות לטעון את המשאבים מיד. +* אין תועלת ב-prefetch לאותו שרת שעליו מתארח דף הווב עצמו, כי lookup אליו כבר בוצע עד לזמן שבו היה ניתן הרמז. +* בהשוואה ל-[`preconnect`](/reference/react-dom/preconnect), ייתכן ש-`prefetchDNS` עדיף אם אתם מתחברים ספקולטיבית למספר גדול של דומיינים, מצב שבו העלות של preconnections עלולה לעלות על התועלת. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Prefetching DNS when rendering {/*prefetching-dns-when-rendering*/} +### DNS Prefetch בזמן רינדור {/*prefetching-dns-when-rendering*/} -Call `prefetchDNS` when rendering a component if you know that its children will load external resources from that host. +קראו ל-`prefetchDNS` בזמן רינדור קומפוננטה אם אתם יודעים שהילדים שלה יטענו משאבים חיצוניים מאותו host. ```js import { prefetchDNS } from 'react-dom'; @@ -77,9 +77,9 @@ function AppRoot() { } ``` -### Prefetching DNS in an event handler {/*prefetching-dns-in-an-event-handler*/} +### DNS Prefetch בתוך event handler {/*prefetching-dns-in-an-event-handler*/} -Call `prefetchDNS` in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`prefetchDNS` בתוך event handler לפני מעבר לעמוד או מצב שבהם יידרשו משאבים חיצוניים. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { prefetchDNS } from 'react-dom'; diff --git a/src/content/reference/react-dom/preinit.md b/src/content/reference/react-dom/preinit.md index 5a04528bd..2dd39341f 100644 --- a/src/content/reference/react-dom/preinit.md +++ b/src/content/reference/react-dom/preinit.md @@ -5,19 +5,19 @@ canary: true -The `preinit` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `preinit` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details. +[Frameworks מבוססי React](/learn/start-a-new-react-project) מטפלים לעיתים קרובות בטעינת משאבים בשבילכם, אז ייתכן שלא תצטרכו לקרוא ל-API הזה בעצמכם. לפרטים, עיינו בתיעוד של ה-framework שלכם. -`preinit` lets you eagerly fetch and evaluate a stylesheet or external script. +`preinit` מאפשרת להביא מראש ולהעריך stylesheet או סקריפט חיצוני. ```js preinit("https://example.com/script.js", {as: "style"}); @@ -33,7 +33,7 @@ preinit("https://example.com/script.js", {as: "style"}); ### `preinit(href, options)` {/*preinit*/} -To preinit a script or stylesheet, call the `preinit` function from `react-dom`. +כדי לבצע preinit לסקריפט או stylesheet, קראו לפונקציה `preinit` מתוך `react-dom`. ```js import { preinit } from 'react-dom'; @@ -45,42 +45,42 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The `preinit` function provides the browser with a hint that it should start downloading and executing the given resource, which can save time. Scripts that you `preinit` are executed when they finish downloading. Stylesheets that you preinit are inserted into the document, which causes them to go into effect right away. +הפונקציה `preinit` מספקת לדפדפן רמז שכדאי להתחיל להוריד ולהריץ את המשאב הנתון, מה שיכול לחסוך זמן. סקריפטים שמבצעים להם `preinit` יורצו כשהורדתם תסתיים. Stylesheets שמבצעים להם preinit יוכנסו למסמך וייכנסו לפעולה מיד. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the resource you want to download and execute. -* `options`: an object. It contains the following properties: - * `as`: a required string. The type of resource. Its possible values are `script` and `style`. - * `precedence`: a string. Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. The possible values are `reset`, `low`, `medium`, `high`. - * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. It is required when `as` is set to `"fetch"`. - * `integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). - * `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. - * `fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and `low`. +* `href`: מחרוזת. ה-URL של המשאב שברצונכם להוריד ולהריץ. +* `options`: אובייקט. כולל את המאפיינים הבאים: + * `as`: מחרוזת חובה. סוג המשאב. הערכים האפשריים: `script` ו-`style`. + * `precedence`: מחרוזת. חובה עבור stylesheets. מציינת איפה להכניס את ה-stylesheet ביחס לאחרים. stylesheets עם קדימות גבוהה יותר יכולים לעקוף כאלה עם קדימות נמוכה יותר. הערכים האפשריים: `reset`, `low`, `medium`, `high`. + * `crossOrigin`: מחרוזת. [מדיניות CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) לשימוש. הערכים האפשריים: `anonymous` ו-`use-credentials`. חובה כשהערך של `as` הוא `"fetch"`. + * `integrity`: מחרוזת. hash קריפטוגרפי של המשאב לצורך [אימות אותנטיות](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). + * `nonce`: מחרוזת. [nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) קריפטוגרפי שמאפשר את המשאב כשמשתמשים ב-Content Security Policy קשוחה. + * `fetchPriority`: מחרוזת. מציעה עדיפות יחסית לטעינת המשאב. הערכים האפשריים: `auto` (ברירת מחדל), `high`, ו-`low`. #### Returns {/*returns*/} -`preinit` returns nothing. +`preinit` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple calls to `preinit` with the same `href` have the same effect as a single call. -* In the browser, you can call `preinit` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preinit` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. +* כמה קריאות ל-`preinit` עם אותו `href` משפיעות כמו קריאה אחת. +* בדפדפן אפשר לקרוא ל-`preinit` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`preinit` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Preiniting when rendering {/*preiniting-when-rendering*/} +### Preinit בזמן רינדור {/*preiniting-when-rendering*/} -Call `preinit` when rendering a component if you know that it or its children will use a specific resource, and you're OK with the resource being evaluated and thereby taking effect immediately upon being downloaded. +קראו ל-`preinit` בזמן רינדור קומפוננטה אם אתם יודעים שהיא או הילדים שלה ישתמשו במשאב ספציפי, ואם מקובל עליכם שהמשאב יוערך וייכנס לפעולה מיד כשהורדתו מסתיימת. -#### Preiniting an external script {/*preiniting-an-external-script*/} +#### Preinit לסקריפט חיצוני {/*preiniting-an-external-script*/} ```js import { preinit } from 'react-dom'; @@ -91,11 +91,11 @@ function AppRoot() { } ``` -If you want the browser to download the script but not to execute it right away, use [`preload`](/reference/react-dom/preload) instead. If you want to load an ESM module, use [`preinitModule`](/reference/react-dom/preinitModule). +אם אתם רוצים שהדפדפן יוריד את הסקריפט אבל לא יריץ אותו מיד, השתמשו ב-[`preload`](/reference/react-dom/preload) במקום. אם רוצים לטעון מודול ESM, השתמשו ב-[`preinitModule`](/reference/react-dom/preinitModule). -#### Preiniting a stylesheet {/*preiniting-a-stylesheet*/} +#### Preinit ל-stylesheet {/*preiniting-a-stylesheet*/} ```js import { preinit } from 'react-dom'; @@ -106,17 +106,17 @@ function AppRoot() { } ``` -The `precedence` option, which is required, lets you control the order of stylesheets within the document. Stylesheets with higher precedence can overrule those with lower precedence. +האפשרות `precedence`, שהיא חובה, מאפשרת לשלוט בסדר של stylesheets בתוך המסמך. stylesheets עם קדימות גבוהה יותר יכולים לעקוף כאלה עם קדימות נמוכה יותר. -If you want to download the stylesheet but not to insert it into the document right away, use [`preload`](/reference/react-dom/preload) instead. +אם אתם רוצים להוריד את ה-stylesheet אבל לא להכניס אותו למסמך מיד, השתמשו ב-[`preload`](/reference/react-dom/preload) במקום. -### Preiniting in an event handler {/*preiniting-in-an-event-handler*/} +### Preinit בתוך event handler {/*preiniting-in-an-event-handler*/} -Call `preinit` in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`preinit` בתוך event handler לפני מעבר לעמוד או מצב שבהם יידרשו משאבים חיצוניים. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { preinit } from 'react-dom'; diff --git a/src/content/reference/react-dom/preinitModule.md b/src/content/reference/react-dom/preinitModule.md index ba6316a7a..bc2a0f829 100644 --- a/src/content/reference/react-dom/preinitModule.md +++ b/src/content/reference/react-dom/preinitModule.md @@ -5,19 +5,19 @@ canary: true -The `preinitModule` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `preinitModule` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details. +[Frameworks מבוססי React](/learn/start-a-new-react-project) מטפלים לעיתים קרובות בטעינת משאבים בשבילכם, אז ייתכן שלא תצטרכו לקרוא ל-API הזה בעצמכם. לפרטים, עיינו בתיעוד של ה-framework שלכם. -`preinitModule` lets you eagerly fetch and evaluate an ESM module. +`preinitModule` מאפשרת להביא מראש מודול ESM ולהעריך אותו. ```js preinitModule("https://example.com/module.js", {as: "script"}); @@ -33,7 +33,7 @@ preinitModule("https://example.com/module.js", {as: "script"}); ### `preinitModule(href, options)` {/*preinitmodule*/} -To preinit an ESM module, call the `preinitModule` function from `react-dom`. +כדי לבצע preinit למודול ESM, קראו לפונקציה `preinitModule` מתוך `react-dom`. ```js import { preinitModule } from 'react-dom'; @@ -45,36 +45,36 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The `preinitModule` function provides the browser with a hint that it should start downloading and executing the given module, which can save time. Modules that you `preinit` are executed when they finish downloading. +הפונקציה `preinitModule` מספקת לדפדפן רמז שכדאי להתחיל להוריד ולהריץ את המודול הנתון, מה שיכול לחסוך זמן. מודולים שמבצעים להם `preinit` יורצו כשיסיימו לרדת. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the module you want to download and exeucute. -* `options`: an object. It contains the following properties: - * `as`: a required string. It must be `'script'`. - * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. - * `integrity`: a string. A cryptographic hash of the module, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). - * `nonce`: a string. A cryptographic [nonce to allow the module](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. +* `href`: מחרוזת. ה-URL של המודול שברצונכם להוריד ולהריץ. +* `options`: אובייקט. כולל את המאפיינים הבאים: + * `as`: מחרוזת חובה. חייב להיות `'script'`. + * `crossOrigin`: מחרוזת. [מדיניות CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) לשימוש. הערכים האפשריים: `anonymous` ו-`use-credentials`. + * `integrity`: מחרוזת. hash קריפטוגרפי של המודול לצורך [אימות אותנטיות](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). + * `nonce`: מחרוזת. [nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) קריפטוגרפי שמאפשר את המודול כשמשתמשים ב-Content Security Policy קשוחה. #### Returns {/*returns*/} -`preinitModule` returns nothing. +`preinitModule` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple calls to `preinitModule` with the same `href` have the same effect as a single call. -* In the browser, you can call `preinitModule` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preinitModule` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. +* כמה קריאות ל-`preinitModule` עם אותו `href` משפיעות כמו קריאה אחת. +* בדפדפן אפשר לקרוא ל-`preinitModule` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`preinitModule` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Preloading when rendering {/*preloading-when-rendering*/} +### Preloading בזמן רינדור {/*preloading-when-rendering*/} -Call `preinitModule` when rendering a component if you know that it or its children will use a specific module and you're OK with the module being evaluated and thereby taking effect immediately upon being downloaded. +קראו ל-`preinitModule` בזמן רינדור קומפוננטה אם אתם יודעים שהיא או הילדים שלה ישתמשו במודול ספציפי, ואם מקובל עליכם שהמודול יוערך וייכנס לפעולה מיד כשהורדתו מסתיימת. ```js import { preinitModule } from 'react-dom'; @@ -85,11 +85,11 @@ function AppRoot() { } ``` -If you want the browser to download the module but not to execute it right away, use [`preloadModule`](/reference/react-dom/preloadModule) instead. If you want to preinit a script that isn't an ESM module, use [`preinit`](/reference/react-dom/preinit). +אם אתם רוצים שהדפדפן יוריד את המודול אבל לא יריץ אותו מייד, השתמשו ב-[`preloadModule`](/reference/react-dom/preloadModule) במקום. אם אתם רוצים לבצע preinit לסקריפט שאינו מודול ESM, השתמשו ב-[`preinit`](/reference/react-dom/preinit). -### Preloading in an event handler {/*preloading-in-an-event-handler*/} +### Preloading בתוך event handler {/*preloading-in-an-event-handler*/} -Call `preinitModule` in an event handler before transitioning to a page or state where the module will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`preinitModule` בתוך event handler לפני מעבר לעמוד או מצב שבהם המודול יידרש. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { preinitModule } from 'react-dom'; diff --git a/src/content/reference/react-dom/preload.md b/src/content/reference/react-dom/preload.md index 0ad9668d2..b473e0a35 100644 --- a/src/content/reference/react-dom/preload.md +++ b/src/content/reference/react-dom/preload.md @@ -5,19 +5,19 @@ canary: true -The `preload` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `preload` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details. +[Frameworks מבוססי React](/learn/start-a-new-react-project) מטפלים לעיתים קרובות בטעינת משאבים בשבילכם, אז ייתכן שלא תצטרכו לקרוא ל-API הזה בעצמכם. לפרטים, עיינו בתיעוד של ה-framework שלכם. -`preload` lets you eagerly fetch a resource such as a stylesheet, font, or external script that you expect to use. +`preload` מאפשרת להביא מראש משאב כמו stylesheet, font, או סקריפט חיצוני שאתם מצפים להשתמש בו. ```js preload("https://example.com/font.woff2", {as: "font"}); @@ -33,7 +33,7 @@ preload("https://example.com/font.woff2", {as: "font"}); ### `preload(href, options)` {/*preload*/} -To preload a resource, call the `preload` function from `react-dom`. +כדי לבצע preload למשאב, קראו לפונקציה `preload` מתוך `react-dom`. ```js import { preload } from 'react-dom'; @@ -45,47 +45,47 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The `preload` function provides the browser with a hint that it should start downloading the given resource, which can save time. +הפונקציה `preload` מספקת לדפדפן רמז שכדאי להתחיל להוריד את המשאב הנתון, מה שיכול לחסוך זמן. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the resource you want to download. -* `options`: an object. It contains the following properties: - * `as`: a required string. The type of resource. Its [possible values](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#as) are `audio`, `document`, `embed`, `fetch`, `font`, `image`, `object`, `script`, `style`, `track`, `video`, `worker`. - * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. It is required when `as` is set to `"fetch"`. - * `referrerPolicy`: a string. The [Referrer header](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#referrerpolicy) to send when fetching. Its possible values are `no-referrer-when-downgrade` (the default), `no-referrer`, `origin`, `origin-when-cross-origin`, and `unsafe-url`. - * `integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). - * `type`: a string. The MIME type of the resource. - * `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. - * `fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and `low`. - * `imageSrcSet`: a string. For use only with `as: "image"`. Specifies the [source set of the image](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). - * `imageSizes`: a string. For use only with `as: "image"`. Specifies the [sizes of the image](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). +* `href`: מחרוזת. ה-URL של המשאב שברצונכם להוריד. +* `options`: אובייקט. כולל את המאפיינים הבאים: + * `as`: מחרוזת חובה. סוג המשאב. [הערכים האפשריים](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#as): `audio`, `document`, `embed`, `fetch`, `font`, `image`, `object`, `script`, `style`, `track`, `video`, `worker`. + * `crossOrigin`: מחרוזת. [מדיניות CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) לשימוש. הערכים האפשריים: `anonymous` ו-`use-credentials`. חובה כשהערך של `as` הוא `"fetch"`. + * `referrerPolicy`: מחרוזת. [כותרת Referrer](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#referrerpolicy) שתישלח בזמן הטעינה. הערכים האפשריים: `no-referrer-when-downgrade` (ברירת מחדל), `no-referrer`, `origin`, `origin-when-cross-origin`, ו-`unsafe-url`. + * `integrity`: מחרוזת. hash קריפטוגרפי של המשאב לצורך [אימות אותנטיות](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). + * `type`: מחרוזת. סוג ה-MIME של המשאב. + * `nonce`: מחרוזת. [nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) קריפטוגרפי שמאפשר את המשאב כשמשתמשים ב-Content Security Policy קשוחה. + * `fetchPriority`: מחרוזת. מציעה עדיפות יחסית לטעינת המשאב. הערכים האפשריים: `auto` (ברירת מחדל), `high`, ו-`low`. + * `imageSrcSet`: מחרוזת. לשימוש רק עם `as: "image"`. מציינת את [source set של התמונה](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). + * `imageSizes`: מחרוזת. לשימוש רק עם `as: "image"`. מציינת את [הגדלים של התמונה](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). #### Returns {/*returns*/} -`preload` returns nothing. +`preload` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple equivalent calls to `preload` have the same effect as a single call. Calls to `preload` are considered equivalent according to the following rules: - * Two calls are equivalent if they have the same `href`, except: - * If `as` is set to `image`, two calls are equivalent if they have the same `href`, `imageSrcSet`, and `imageSizes`. -* In the browser, you can call `preload` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preload` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. +* כמה קריאות שקולות ל-`preload` משפיעות כמו קריאה אחת. קריאות ל-`preload` נחשבות שקולות לפי הכללים האלה: + * שתי קריאות שקולות אם יש להן אותו `href`, חוץ מהמקרה הבא: + * אם `as` מוגדר כ-`image`, שתי קריאות שקולות אם יש להן אותו `href`, `imageSrcSet`, ו-`imageSizes`. +* בדפדפן אפשר לקרוא ל-`preload` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`preload` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Preloading when rendering {/*preloading-when-rendering*/} +### Preloading בזמן רינדור {/*preloading-when-rendering*/} -Call `preload` when rendering a component if you know that it or its children will use a specific resource. +קראו ל-`preload` בזמן רינדור קומפוננטה אם אתם יודעים שהיא או הילדים שלה ישתמשו במשאב ספציפי. -#### Preloading an external script {/*preloading-an-external-script*/} +#### Preloading לסקריפט חיצוני {/*preloading-an-external-script*/} ```js import { preload } from 'react-dom'; @@ -96,11 +96,11 @@ function AppRoot() { } ``` -If you want the browser to start executing the script immediately (rather than just downloading it), use [`preinit`](/reference/react-dom/preinit) instead. If you want to load an ESM module, use [`preloadModule`](/reference/react-dom/preloadModule). +אם אתם רוצים שהדפדפן יתחיל להריץ את הסקריפט מיד (ולא רק להוריד אותו), השתמשו ב-[`preinit`](/reference/react-dom/preinit) במקום. אם רוצים לטעון מודול ESM, השתמשו ב-[`preloadModule`](/reference/react-dom/preloadModule). -#### Preloading a stylesheet {/*preloading-a-stylesheet*/} +#### Preloading ל-stylesheet {/*preloading-a-stylesheet*/} ```js import { preload } from 'react-dom'; @@ -111,11 +111,11 @@ function AppRoot() { } ``` -If you want the stylesheet to be inserted into the document immediately (which means the browser will start parsing it immediately rather than just downloading it), use [`preinit`](/reference/react-dom/preinit) instead. +אם אתם רוצים שה-stylesheet יוכנס למסמך מיד (כלומר שהדפדפן יתחיל לפרש אותו מייד ולא רק להוריד אותו), השתמשו ב-[`preinit`](/reference/react-dom/preinit) במקום. -#### Preloading a font {/*preloading-a-font*/} +#### Preloading לפונט {/*preloading-a-font*/} ```js import { preload } from 'react-dom'; @@ -127,11 +127,11 @@ function AppRoot() { } ``` -If you preload a stylesheet, it's smart to also preload any fonts that the stylesheet refers to. That way, the browser can start downloading the font before it's downloaded and parsed the stylesheet. +אם אתם מבצעים preload ל-stylesheet, חכם לבצע preload גם לפונטים שה-stylesheet מפנה אליהם. כך הדפדפן יכול להתחיל להוריד את הפונט עוד לפני שה-stylesheet יורד ומפורש. -#### Preloading an image {/*preloading-an-image*/} +#### Preloading לתמונה {/*preloading-an-image*/} ```js import { preload } from 'react-dom'; @@ -146,15 +146,15 @@ function AppRoot() { } ``` -When preloading an image, the `imageSrcSet` and `imageSizes` options help the browser [fetch the correctly sized image for the size of the screen](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). +כשמבצעים preload לתמונה, האפשרויות `imageSrcSet` ו-`imageSizes` עוזרות לדפדפן [להביא את התמונה בגודל הנכון לגודל המסך](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). -### Preloading in an event handler {/*preloading-in-an-event-handler*/} +### Preloading בתוך event handler {/*preloading-in-an-event-handler*/} -Call `preload` in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`preload` בתוך event handler לפני מעבר לעמוד או מצב שבהם יידרשו משאבים חיצוניים. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { preload } from 'react-dom'; diff --git a/src/content/reference/react-dom/preloadModule.md b/src/content/reference/react-dom/preloadModule.md index 05333f1cb..35025721b 100644 --- a/src/content/reference/react-dom/preloadModule.md +++ b/src/content/reference/react-dom/preloadModule.md @@ -5,19 +5,19 @@ canary: true -The `preloadModule` function is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels). +הפונקציה `preloadModule` זמינה כרגע רק בערוצי Canary ו-experimental של React. מידע נוסף ב-[ערוצי השחרור של React](/community/versioning-policy#all-release-channels). -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details. +[Frameworks מבוססי React](/learn/start-a-new-react-project) מטפלים לעיתים קרובות בטעינת משאבים בשבילכם, אז ייתכן שלא תצטרכו לקרוא ל-API הזה בעצמכם. לפרטים, עיינו בתיעוד של ה-framework שלכם. -`preloadModule` lets you eagerly fetch an ESM module that you expect to use. +`preloadModule` מאפשרת להביא מראש מודול ESM שאתם מצפים להשתמש בו. ```js preloadModule("https://example.com/module.js", {as: "script"}); @@ -33,7 +33,7 @@ preloadModule("https://example.com/module.js", {as: "script"}); ### `preloadModule(href, options)` {/*preloadmodule*/} -To preload an ESM module, call the `preloadModule` function from `react-dom`. +כדי לבצע preload למודול ESM, קראו לפונקציה `preloadModule` מתוך `react-dom`. ```js import { preloadModule } from 'react-dom'; @@ -45,37 +45,37 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The `preloadModule` function provides the browser with a hint that it should start downloading the given module, which can save time. +הפונקציה `preloadModule` מספקת לדפדפן רמז שכדאי להתחיל להוריד את המודול הנתון, מה שיכול לחסוך זמן. #### Parameters {/*parameters*/} -* `href`: a string. The URL of the module you want to download. -* `options`: an object. It contains the following properties: - * `as`: a required string. It must be `'script'`. - * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. - * `integrity`: a string. A cryptographic hash of the module, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). - * `nonce`: a string. A cryptographic [nonce to allow the module](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. +* `href`: מחרוזת. ה-URL של המודול שברצונכם להוריד. +* `options`: אובייקט. כולל את המאפיינים הבאים: + * `as`: מחרוזת חובה. חייב להיות `'script'`. + * `crossOrigin`: מחרוזת. [מדיניות CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) לשימוש. הערכים האפשריים: `anonymous` ו-`use-credentials`. + * `integrity`: מחרוזת. hash קריפטוגרפי של המודול לצורך [אימות אותנטיות](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). + * `nonce`: מחרוזת. [nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) קריפטוגרפי שמאפשר את המודול כשמשתמשים ב-Content Security Policy קשוחה. #### Returns {/*returns*/} -`preloadModule` returns nothing. +`preloadModule` לא מחזירה דבר. #### Caveats {/*caveats*/} -* Multiple calls to `preloadModule` with the same `href` have the same effect as a single call. -* In the browser, you can call `preloadModule` in any situation: while rendering a component, in an effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preloadModule` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. +* כמה קריאות ל-`preloadModule` עם אותו `href` משפיעות כמו קריאה אחת. +* בדפדפן אפשר לקרוא ל-`preloadModule` בכל מצב: בזמן רינדור קומפוננטה, בתוך effect, בתוך event handler, וכן הלאה. +* ברינדור צד שרת או ברינדור Server Components, ל-`preloadModule` יש השפעה רק אם קוראים לה בזמן רינדור קומפוננטה או בהקשר async שמקורו ברינדור קומפוננטה. קריאות אחרות ייחסמו. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Preloading when rendering {/*preloading-when-rendering*/} +### Preloading בזמן רינדור {/*preloading-when-rendering*/} -Call `preloadModule` when rendering a component if you know that it or its children will use a specific module. +קראו ל-`preloadModule` בזמן רינדור קומפוננטה אם אתם יודעים שהיא או הילדים שלה ישתמשו במודול ספציפי. ```js import { preloadModule } from 'react-dom'; @@ -86,11 +86,11 @@ function AppRoot() { } ``` -If you want the browser to start executing the module immediately (rather than just downloading it), use [`preinitModule`](/reference/react-dom/preinitModule) instead. If you want to load a script that isn't an ESM module, use [`preload`](/reference/react-dom/preload). +אם אתם רוצים שהדפדפן יתחיל גם להריץ את המודול מיד (ולא רק להוריד אותו), השתמשו ב-[`preinitModule`](/reference/react-dom/preinitModule) במקום. אם אתם רוצים לטעון סקריפט שאינו מודול ESM, השתמשו ב-[`preload`](/reference/react-dom/preload). -### Preloading in an event handler {/*preloading-in-an-event-handler*/} +### Preloading בתוך event handler {/*preloading-in-an-event-handler*/} -Call `preloadModule` in an event handler before transitioning to a page or state where the module will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +קראו ל-`preloadModule` בתוך event handler לפני מעבר לעמוד או מצב שבהם המודול יידרש. כך התהליך מתחיל מוקדם יותר לעומת קריאה בזמן רינדור העמוד או המצב החדש. ```js import { preloadModule } from 'react-dom'; diff --git a/src/content/reference/react-dom/render.md b/src/content/reference/react-dom/render.md index 03feb2881..5efba2bfb 100644 --- a/src/content/reference/react-dom/render.md +++ b/src/content/reference/react-dom/render.md @@ -4,15 +4,15 @@ title: render -This API will be removed in a future major version of React. +ה-API הזה יוסר בגרסה ראשית עתידית של React. -In React 18, `render` was replaced by [`createRoot`.](/reference/react-dom/client/createRoot) Using `render` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis) +ב-React 18, `render` הוחלפה ב-[`createRoot`.](/reference/react-dom/client/createRoot) שימוש ב-`render` ב-React 18 יציג אזהרה שהאפליקציה שלכם תתנהג כאילו היא רצה על React 17. מידע נוסף [כאן.](/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis) -`render` renders a piece of [JSX](/learn/writing-markup-with-jsx) ("React node") into a browser DOM node. +`render` מרנדרת חתיכת [JSX](/learn/writing-markup-with-jsx) ("React node") לתוך DOM node של דפדפן. ```js render(reactNode, domNode, callback?) @@ -28,7 +28,7 @@ render(reactNode, domNode, callback?) ### `render(reactNode, domNode, callback?)` {/*render*/} -Call `render` to display a React component inside a browser DOM element. +קראו ל-`render` כדי להציג קומפוננטת React בתוך אלמנט DOM של דפדפן. ```js import { render } from 'react-dom'; @@ -37,40 +37,40 @@ const domNode = document.getElementById('root'); render(, domNode); ``` -React will display `` in the `domNode`, and take over managing the DOM inside it. +React תציג את `` בתוך `domNode`, ותיקח שליטה על ניהול ה-DOM שבתוכו. -An app fully built with React will usually only have one `render` call with its root component. A page that uses "sprinkles" of React for parts of the page may have as many `render` calls as needed. +אפליקציה שבנויה כולה ב-React לרוב תכלול רק קריאת `render` אחת עם קומפוננטת השורש שלה. עמוד שמשתמש ב"sprinkles" של React בחלקים שונים עשוי לכלול כמה קריאות `render` לפי הצורך. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `reactNode`: A *React node* that you want to display. This will usually be a piece of JSX like ``, but you can also pass a React element constructed with [`createElement()`](/reference/react/createElement), a string, a number, `null`, or `undefined`. +* `reactNode`: ‏*React node* שברצונכם להציג. בדרך כלל זו תהיה חתיכת JSX כמו ``, אבל אפשר גם להעביר React element שנוצר עם [`createElement()`](/reference/react/createElement), מחרוזת, מספר, `null`, או `undefined`. -* `domNode`: A [DOM element.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React will display the `reactNode` you pass inside this DOM element. From this moment, React will manage the DOM inside the `domNode` and update it when your React tree changes. +* `domNode`: [אלמנט DOM.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React תציג את `reactNode` שהעברתם בתוך אלמנט ה-DOM הזה. מהרגע הזה React תנהל את ה-DOM בתוך `domNode` ותעדכן אותו כשהעץ של React ישתנה. -* **optional** `callback`: A function. If passed, React will call it after your component is placed into the DOM. +* **אופציונלי** `callback`: פונקציה. אם הועברה, React תקרא לה אחרי שהקומפוננטה הוכנסה ל-DOM. #### Returns {/*returns*/} -`render` usually returns `null`. However, if the `reactNode` you pass is a *class component*, then it will return an instance of that component. +`render` בדרך כלל מחזירה `null`. עם זאת, אם `reactNode` שהעברתם היא *class component*, יוחזר מופע של הקומפוננטה הזו. #### Caveats {/*caveats*/} -* In React 18, `render` was replaced by [`createRoot`.](/reference/react-dom/client/createRoot) Please use `createRoot` for React 18 and beyond. +* ב-React 18, `render` הוחלפה ב-[`createRoot`.](/reference/react-dom/client/createRoot) השתמשו ב-`createRoot` עבור React 18 ומעלה. -* The first time you call `render`, React will clear all the existing HTML content inside the `domNode` before rendering the React component into it. If your `domNode` contains HTML generated by React on the server or during the build, use [`hydrate()`](/reference/react-dom/hydrate) instead, which attaches the event handlers to the existing HTML. +* בפעם הראשונה שקוראים ל-`render`, React תנקה את כל תוכן ה-HTML הקיים בתוך `domNode` לפני רינדור קומפוננטת React לתוכה. אם ה-`domNode` שלכם מכילה HTML שנוצר על ידי React בשרת או בזמן build, השתמשו ב-[`hydrate()`](/reference/react-dom/hydrate) במקום, שמחברת את event handlers ל-HTML הקיים. -* If you call `render` on the same `domNode` more than once, React will update the DOM as necessary to reflect the latest JSX you passed. React will decide which parts of the DOM can be reused and which need to be recreated by ["matching it up"](/learn/preserving-and-resetting-state) with the previously rendered tree. Calling `render` on the same `domNode` again is similar to calling the [`set` function](/reference/react/useState#setstate) on the root component: React avoids unnecessary DOM updates. +* אם תקראו ל-`render` על אותו `domNode` יותר מפעם אחת, React תעדכן את ה-DOM לפי הצורך כדי לשקף את ה-JSX העדכני ביותר שהעברתם. React תחליט אילו חלקים ב-DOM אפשר למחזר ואילו צריך ליצור מחדש על ידי ["התאמה"](/learn/preserving-and-resetting-state) לעץ שרונדר קודם. קריאה נוספת ל-`render` על אותו `domNode` דומה לקריאה ל-[פונקציית `set`](/reference/react/useState#setstate) בקומפוננטת השורש: React נמנעת מעדכוני DOM מיותרים. -* If your app is fully built with React, you'll likely have only one `render` call in your app. (If you use a framework, it might do this call for you.) When you want to render a piece of JSX in a different part of the DOM tree that isn't a child of your component (for example, a modal or a tooltip), use [`createPortal`](/reference/react-dom/createPortal) instead of `render`. +* אם האפליקציה שלכם בנויה לגמרי ב-React, כנראה שתהיה בה רק קריאת `render` אחת. (אם אתם משתמשים ב-framework, הוא עשוי לבצע את הקריאה הזו עבורכם.) כשאתם רוצים לרנדר חתיכת JSX בחלק אחר של עץ ה-DOM שאינו ילד של הקומפוננטה שלכם (למשל modal או tooltip), השתמשו ב-[`createPortal`](/reference/react-dom/createPortal) במקום ב-`render`. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -Call `render` to display a React component inside a browser DOM node. +קראו ל-`render` כדי להציג קומפוננטת React בתוך DOM node של דפדפן. ```js [[1, 4, ""], [2, 4, "document.getElementById('root')"]] import { render } from 'react-dom'; @@ -79,9 +79,9 @@ import App from './App.js'; render(, document.getElementById('root')); ``` -### Rendering the root component {/*rendering-the-root-component*/} +### רינדור קומפוננטת השורש {/*rendering-the-root-component*/} -In apps fully built with React, **you will usually only do this once at startup**--to render the "root" component. +באפליקציות שבנויות לגמרי עם React, **בדרך כלל עושים את זה פעם אחת בלבד בזמן ההפעלה** — כדי לרנדר את קומפוננטת ה"שורש". @@ -101,13 +101,13 @@ export default function App() { -Usually you shouldn't need to call `render` again or to call it in more places. From this point on, React will be managing the DOM of your application. To update the UI, your components will [use state.](/reference/react/useState) +בדרך כלל לא צריך לקרוא ל-`render` שוב או לקרוא לה במקומות נוספים. מהנקודה הזו React תנהל את ה-DOM של האפליקציה. כדי לעדכן את ה-UI, הקומפוננטות שלכם [ישתמשו ב-state.](/reference/react/useState) --- -### Rendering multiple roots {/*rendering-multiple-roots*/} +### רינדור כמה roots {/*rendering-multiple-roots*/} -If your page [isn't fully built with React](/learn/add-react-to-an-existing-project#using-react-for-a-part-of-your-existing-page), call `render` for each top-level piece of UI managed by React. +אם העמוד שלכם [לא בנוי כולו ב-React](/learn/add-react-to-an-existing-project#using-react-for-a-part-of-your-existing-page), קראו ל-`render` עבור כל יחידת UI עליונה שמנוהלת על ידי React. @@ -177,13 +177,13 @@ nav ul li { display: inline-block; margin-right: 20px; } -You can destroy the rendered trees with [`unmountComponentAtNode()`.](/reference/react-dom/unmountComponentAtNode) +אפשר להשמיד את העצים שרונדרו עם [`unmountComponentAtNode()`.](/reference/react-dom/unmountComponentAtNode) --- -### Updating the rendered tree {/*updating-the-rendered-tree*/} +### עדכון העץ המרונדר {/*updating-the-rendered-tree*/} -You can call `render` more than once on the same DOM node. As long as the component tree structure matches up with what was previously rendered, React will [preserve the state.](/learn/preserving-and-resetting-state) Notice how you can type in the input, which means that the updates from repeated `render` calls every second are not destructive: +אפשר לקרוא ל-`render` יותר מפעם אחת על אותו DOM node. כל עוד מבנה עץ הקומפוננטות תואם למה שרונדר קודם, React [תשמר את ה-state.](/learn/preserving-and-resetting-state) שימו לב שאפשר להקליד ב-input, כלומר העדכונים מקריאות `render` חוזרות כל שנייה אינם הרסניים: @@ -215,4 +215,4 @@ export default function App({counter}) { -It is uncommon to call `render` multiple times. Usually, you'll [update state](/reference/react/useState) inside your components instead. +לא נפוץ לקרוא ל-`render` כמה פעמים. בדרך כלל תעדכנו [state](/reference/react/useState) בתוך הקומפוננטות במקום. diff --git a/src/content/reference/react-dom/server/index.md b/src/content/reference/react-dom/server/index.md index f90f7c183..19e6d0bf0 100644 --- a/src/content/reference/react-dom/server/index.md +++ b/src/content/reference/react-dom/server/index.md @@ -4,46 +4,46 @@ title: Server React DOM APIs -The `react-dom/server` APIs let you render React components to HTML on the server. These APIs are only used on the server at the top level of your app to generate the initial HTML. A [framework](/learn/start-a-new-react-project#production-grade-react-frameworks) may call them for you. Most of your components don't need to import or use them. +ה-APIs של `react-dom/server` מאפשרים לרנדר קומפוננטות React ל-HTML בצד שרת. ה-APIs האלה משמשים רק בצד שרת, ברמה העליונה של האפליקציה, כדי לייצר את ה-HTML הראשוני. [Framework](/learn/start-a-new-react-project#production-grade-react-frameworks) יכול לקרוא להם עבורכם. רוב הקומפוננטות שלכם לא צריכות לייבא או להשתמש בהם. --- -## Server APIs for Node.js Streams {/*server-apis-for-nodejs-streams*/} +## Server APIs עבור Node.js Streams {/*server-apis-for-nodejs-streams*/} -These methods are only available in the environments with [Node.js Streams:](https://nodejs.org/api/stream.html) +המתודות האלה זמינות רק בסביבות עם [Node.js Streams:](https://nodejs.org/api/stream.html) -* [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) renders a React tree to a pipeable [Node.js Stream.](https://nodejs.org/api/stream.html) -* [`renderToStaticNodeStream`](/reference/react-dom/server/renderToStaticNodeStream) renders a non-interactive React tree to a [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) +* [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) מרנדר עץ React ל-[Node.js Stream](https://nodejs.org/api/stream.html) שניתן לבצע לו piping. +* [`renderToStaticNodeStream`](/reference/react-dom/server/renderToStaticNodeStream) מרנדר עץ React לא אינטראקטיבי ל-[Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) --- -## Server APIs for Web Streams {/*server-apis-for-web-streams*/} +## Server APIs עבור Web Streams {/*server-apis-for-web-streams*/} -These methods are only available in the environments with [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), which includes browsers, Deno, and some modern edge runtimes: +המתודות האלה זמינות רק בסביבות עם [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), כולל דפדפנים, Deno, וחלק מסביבות edge מודרניות: -* [`renderToReadableStream`](/reference/react-dom/server/renderToReadableStream) renders a React tree to a [Readable Web Stream.](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) +* [`renderToReadableStream`](/reference/react-dom/server/renderToReadableStream) מרנדר עץ React ל-[Readable Web Stream.](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) --- -## Server APIs for non-streaming environments {/*server-apis-for-non-streaming-environments*/} +## Server APIs עבור סביבות ללא streaming {/*server-apis-for-non-streaming-environments*/} -These methods can be used in the environments that don't support streams: +אפשר להשתמש במתודות האלה בסביבות שלא תומכות ב-streams: -* [`renderToString`](/reference/react-dom/server/renderToString) renders a React tree to a string. -* [`renderToStaticMarkup`](/reference/react-dom/server/renderToStaticMarkup) renders a non-interactive React tree to a string. +* [`renderToString`](/reference/react-dom/server/renderToString) מרנדר עץ React למחרוזת. +* [`renderToStaticMarkup`](/reference/react-dom/server/renderToStaticMarkup) מרנדר עץ React לא אינטראקטיבי למחרוזת. -They have limited functionality compared to the streaming APIs. +יש להן פונקציונליות מוגבלת בהשוואה ל-APIs של streaming. --- -## Deprecated server APIs {/*deprecated-server-apis*/} +## Server APIs שהוצאו משימוש {/*deprecated-server-apis*/} -These APIs will be removed in a future major version of React. +ה-APIs האלה יוסרו בגרסה ראשית עתידית של React. -* [`renderToNodeStream`](/reference/react-dom/server/renderToNodeStream) renders a React tree to a [Node.js Readable stream.](https://nodejs.org/api/stream.html#readable-streams) (Deprecated.) +* [`renderToNodeStream`](/reference/react-dom/server/renderToNodeStream) מרנדר עץ React ל-[Node.js Readable stream.](https://nodejs.org/api/stream.html#readable-streams) (הוצא משימוש.) diff --git a/src/content/reference/react-dom/server/renderToNodeStream.md b/src/content/reference/react-dom/server/renderToNodeStream.md index aa2c2e8fc..4168eae2a 100644 --- a/src/content/reference/react-dom/server/renderToNodeStream.md +++ b/src/content/reference/react-dom/server/renderToNodeStream.md @@ -4,13 +4,13 @@ title: renderToNodeStream -This API will be removed in a future major version of React. Use [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) instead. +ה-API הזה יוסר בגרסה ראשית עתידית של React. השתמשו ב-[`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) במקום. -`renderToNodeStream` renders a React tree to a [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) +`renderToNodeStream` מרנדר עץ React ל-[Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) ```js const stream = renderToNodeStream(reactNode, options?) @@ -26,7 +26,7 @@ const stream = renderToNodeStream(reactNode, options?) ### `renderToNodeStream(reactNode, options?)` {/*rendertonodestream*/} -On the server, call `renderToNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe into the response. +בשרת, קראו ל-`renderToNodeStream` כדי לקבל [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) שאפשר לבצע לו pipe לתגובה. ```js import { renderToNodeStream } from 'react-dom/server'; @@ -35,36 +35,36 @@ const stream = renderToNodeStream(); stream.pipe(response); ``` -On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to make the server-generated HTML interactive. +בצד הלקוח, קראו ל-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) כדי להפוך את ה-HTML שנוצר בשרת לאינטראקטיבי. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `reactNode`: A React node you want to render to HTML. For example, a JSX element like ``. +* `reactNode`: React node שברצונכם לרנדר ל-HTML. לדוגמה, JSX element כמו ``. -* **optional** `options`: An object for server render. - * **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters) +* **אופציונלי** `options`: אובייקט עבור רינדור שרת. + * **אופציונלי** `identifierPrefix`: מחרוזת קידומת ש-React משתמשת בה עבור מזהים שנוצרים על ידי [`useId`.](/reference/react/useId) שימושי למניעת התנגשויות כשמשתמשים בכמה roots באותו עמוד. חייב להיות זהה לקידומת שמועברת ל-[`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters) #### Returns {/*returns*/} -A [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) that outputs an HTML string. +[Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) שמפיק מחרוזת HTML. #### Caveats {/*caveats*/} -* This method will wait for all [Suspense boundaries](/reference/react/Suspense) to complete before returning any output. +* המתודה הזו תחכה שכל [גבולות Suspense](/reference/react/Suspense) יסתיימו לפני החזרת פלט. -* As of React 18, this method buffers all of its output, so it doesn't actually provide any streaming benefits. This is why it's recommended that you migrate to [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) instead. +* החל מ-React 18, המתודה הזו מאחסנת את כל הפלט בבאפר, ולכן בפועל אינה מספקת יתרונות streaming. לכן מומלץ לעבור ל-[`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream). -* The returned stream is a byte stream encoded in utf-8. If you need a stream in another encoding, take a look at a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text. +* ה-stream המוחזר הוא byte stream בקידוד utf-8. אם צריך stream בקידוד אחר, אפשר לבדוק פרויקט כמו [iconv-lite](https://www.npmjs.com/package/iconv-lite), שמספק transform streams להמרת קידוד טקסט. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Rendering a React tree as HTML to a Node.js Readable Stream {/*rendering-a-react-tree-as-html-to-a-nodejs-readable-stream*/} +### רינדור עץ React כ-HTML ל-Node.js Readable Stream {/*rendering-a-react-tree-as-html-to-a-nodejs-readable-stream*/} -Call `renderToNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe to your server response: +קראו ל-`renderToNodeStream` כדי לקבל [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) שאפשר לבצע לו pipe לתגובת השרת: ```js {5-6} import { renderToNodeStream } from 'react-dom/server'; @@ -76,4 +76,4 @@ app.use('/', (request, response) => { }); ``` -The stream will produce the initial non-interactive HTML output of your React components. On the client, you will need to call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to *hydrate* that server-generated HTML and make it interactive. +ה-stream יפיק את פלט ה-HTML הראשוני הלא אינטראקטיבי של קומפוננטות React שלכם. בצד הלקוח תצטרכו לקרוא ל-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) כדי לבצע *hydration* ל-HTML שנוצר בשרת ולהפוך אותו לאינטראקטיבי. diff --git a/src/content/reference/react-dom/server/renderToStaticMarkup.md b/src/content/reference/react-dom/server/renderToStaticMarkup.md index 2b9178d55..a8b8630c8 100644 --- a/src/content/reference/react-dom/server/renderToStaticMarkup.md +++ b/src/content/reference/react-dom/server/renderToStaticMarkup.md @@ -4,7 +4,7 @@ title: renderToStaticMarkup -`renderToStaticMarkup` renders a non-interactive React tree to an HTML string. +`renderToStaticMarkup` מרנדר עץ React לא אינטראקטיבי למחרוזת HTML. ```js const html = renderToStaticMarkup(reactNode, options?) @@ -20,7 +20,7 @@ const html = renderToStaticMarkup(reactNode, options?) ### `renderToStaticMarkup(reactNode, options?)` {/*rendertostaticmarkup*/} -On the server, call `renderToStaticMarkup` to render your app to HTML. +בצד השרת, קראו ל-`renderToStaticMarkup` כדי לרנדר את האפליקציה שלכם ל-HTML. ```js import { renderToStaticMarkup } from 'react-dom/server'; @@ -28,35 +28,35 @@ import { renderToStaticMarkup } from 'react-dom/server'; const html = renderToStaticMarkup(); ``` -It will produce non-interactive HTML output of your React components. +הפונקציה תייצר פלט HTML לא אינטראקטיבי של קומפוננטות React שלכם. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `reactNode`: A React node you want to render to HTML. For example, a JSX node like ``. -* **optional** `options`: An object for server render. - * **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. +* `reactNode`: React node שברצונכם לרנדר ל-HTML. למשל, JSX node כמו ``. +* **אופציונלי** `options`: אובייקט עבור רינדור שרת. + * **אופציונלי** `identifierPrefix`: מחרוזת קידומת ש-React משתמשת בה עבור מזהים שנוצרים על ידי [`useId`.](/reference/react/useId) שימושי למניעת התנגשויות כשמשתמשים בכמה roots באותו עמוד. #### Returns {/*returns*/} -An HTML string. +מחרוזת HTML. #### Caveats {/*caveats*/} -* `renderToStaticMarkup` output cannot be hydrated. +* אי אפשר לבצע hydration לפלט של `renderToStaticMarkup`. -* `renderToStaticMarkup` has limited Suspense support. If a component suspends, `renderToStaticMarkup` immediately sends its fallback as HTML. +* ל-`renderToStaticMarkup` יש תמיכה מוגבלת ב-Suspense. אם קומפוננטה מבצעת suspend, `renderToStaticMarkup` שולחת מיד את ה-fallback שלה כ-HTML. -* `renderToStaticMarkup` works in the browser, but using it in the client code is not recommended. If you need to render a component to HTML in the browser, [get the HTML by rendering it into a DOM node.](/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code) +* `renderToStaticMarkup` עובדת גם בדפדפן, אבל לא מומלץ להשתמש בה בקוד לקוח. אם צריך לרנדר קומפוננטה ל-HTML בדפדפן, [קבלו את ה-HTML על ידי רינדור ל-DOM node.](/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code) --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Rendering a non-interactive React tree as HTML to a string {/*rendering-a-non-interactive-react-tree-as-html-to-a-string*/} +### רינדור עץ React לא אינטראקטיבי כ-HTML למחרוזת {/*rendering-a-non-interactive-react-tree-as-html-to-a-string*/} -Call `renderToStaticMarkup` to render your app to an HTML string which you can send with your server response: +קראו ל-`renderToStaticMarkup` כדי לרנדר את האפליקציה למחרוזת HTML שאפשר לשלוח בתגובת השרת: ```js {5-6} import { renderToStaticMarkup } from 'react-dom/server'; @@ -68,12 +68,12 @@ app.use('/', (request, response) => { }); ``` -This will produce the initial non-interactive HTML output of your React components. +כך יתקבל פלט ה-HTML הראשוני הלא אינטראקטיבי של קומפוננטות React שלכם. -This method renders **non-interactive HTML that cannot be hydrated.** This is useful if you want to use React as a simple static page generator, or if you're rendering completely static content like emails. +המתודה הזו מרנדרת **HTML לא אינטראקטיבי שאי אפשר לבצע לו hydration.** זה שימושי אם רוצים להשתמש ב-React כמחולל עמודים סטטיים פשוט, או אם מרנדרים תוכן סטטי לחלוטין כמו אימיילים. -Interactive apps should use [`renderToString`](/reference/react-dom/server/renderToString) on the server and [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) on the client. +אפליקציות אינטראקטיביות צריכות להשתמש ב-[`renderToString`](/reference/react-dom/server/renderToString) בצד השרת וב-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) בצד הלקוח. diff --git a/src/content/reference/react-dom/server/renderToStaticNodeStream.md b/src/content/reference/react-dom/server/renderToStaticNodeStream.md index f12b6da2f..f30dcc2b2 100644 --- a/src/content/reference/react-dom/server/renderToStaticNodeStream.md +++ b/src/content/reference/react-dom/server/renderToStaticNodeStream.md @@ -4,7 +4,7 @@ title: renderToStaticNodeStream -`renderToStaticNodeStream` renders a non-interactive React tree to a [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) +`renderToStaticNodeStream` מרנדר עץ React לא אינטראקטיבי ל-[Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams) ```js const stream = renderToStaticNodeStream(reactNode, options?) @@ -20,7 +20,7 @@ const stream = renderToStaticNodeStream(reactNode, options?) ### `renderToStaticNodeStream(reactNode, options?)` {/*rendertostaticnodestream*/} -On the server, call `renderToStaticNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams). +בשרת, קראו ל-`renderToStaticNodeStream` כדי לקבל [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams). ```js import { renderToStaticNodeStream } from 'react-dom/server'; @@ -29,38 +29,38 @@ const stream = renderToStaticNodeStream(); stream.pipe(response); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) -The stream will produce non-interactive HTML output of your React components. +ה-stream יפיק פלט HTML לא אינטראקטיבי של קומפוננטות React שלכם. #### Parameters {/*parameters*/} -* `reactNode`: A React node you want to render to HTML. For example, a JSX element like ``. +* `reactNode`: React node שברצונכם לרנדר ל-HTML. לדוגמה, JSX element כמו ``. -* **optional** `options`: An object for server render. - * **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. +* **אופציונלי** `options`: אובייקט עבור רינדור שרת. + * **אופציונלי** `identifierPrefix`: מחרוזת קידומת ש-React משתמשת בה עבור מזהים שנוצרים על ידי [`useId`.](/reference/react/useId) שימושי למניעת התנגשויות כשמשתמשים בכמה roots באותו עמוד. #### Returns {/*returns*/} -A [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) that outputs an HTML string. The resulting HTML can't be hydrated on the client. +[Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) שמפיק מחרוזת HTML. אי אפשר לבצע hydration ל-HTML שמתקבל. #### Caveats {/*caveats*/} -* `renderToStaticNodeStream` output cannot be hydrated. +* אי אפשר לבצע hydration לפלט של `renderToStaticNodeStream`. -* This method will wait for all [Suspense boundaries](/reference/react/Suspense) to complete before returning any output. +* המתודה הזו תחכה שכל [גבולות Suspense](/reference/react/Suspense) יסתיימו לפני החזרת פלט. -* As of React 18, this method buffers all of its output, so it doesn't actually provide any streaming benefits. +* החל מ-React 18, המתודה הזו מאחסנת את כל הפלט בבאפר, ולכן בפועל אינה מספקת יתרונות streaming. -* The returned stream is a byte stream encoded in utf-8. If you need a stream in another encoding, take a look at a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text. +* ה-stream המוחזר הוא byte stream בקידוד utf-8. אם צריך stream בקידוד אחר, אפשר לבדוק פרויקט כמו [iconv-lite](https://www.npmjs.com/package/iconv-lite), שמספק transform streams להמרת קידוד טקסט. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Rendering a React tree as static HTML to a Node.js Readable Stream {/*rendering-a-react-tree-as-static-html-to-a-nodejs-readable-stream*/} +### רינדור עץ React כ-HTML סטטי ל-Node.js Readable Stream {/*rendering-a-react-tree-as-static-html-to-a-nodejs-readable-stream*/} -Call `renderToStaticNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe to your server response: +קראו ל-`renderToStaticNodeStream` כדי לקבל [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) שאפשר לבצע לו pipe לתגובת השרת: ```js {5-6} import { renderToStaticNodeStream } from 'react-dom/server'; @@ -72,12 +72,12 @@ app.use('/', (request, response) => { }); ``` -The stream will produce the initial non-interactive HTML output of your React components. +ה-stream יפיק את פלט ה-HTML הראשוני הלא אינטראקטיבי של קומפוננטות React שלכם. -This method renders **non-interactive HTML that cannot be hydrated.** This is useful if you want to use React as a simple static page generator, or if you're rendering completely static content like emails. +המתודה הזו מרנדרת **HTML לא אינטראקטיבי שאי אפשר לבצע לו hydration.** זה שימושי אם רוצים להשתמש ב-React כמחולל עמודים סטטיים פשוט, או אם מרנדרים תוכן סטטי לחלוטין כמו אימיילים. -Interactive apps should use [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) on the server and [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) on the client. +אפליקציות אינטראקטיביות צריכות להשתמש ב-[`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) בצד השרת וב-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) בצד הלקוח. diff --git a/src/content/reference/react-dom/server/renderToString.md b/src/content/reference/react-dom/server/renderToString.md index d9f1bdba4..ce9ea2cb9 100644 --- a/src/content/reference/react-dom/server/renderToString.md +++ b/src/content/reference/react-dom/server/renderToString.md @@ -4,13 +4,13 @@ title: renderToString -`renderToString` does not support streaming or waiting for data. [See the alternatives.](#alternatives) +`renderToString` לא תומכת ב-streaming או בהמתנה לנתונים. [ראו חלופות.](#alternatives) -`renderToString` renders a React tree to an HTML string. +`renderToString` מרנדרת עץ React למחרוזת HTML. ```js const html = renderToString(reactNode, options?) @@ -26,7 +26,7 @@ const html = renderToString(reactNode, options?) ### `renderToString(reactNode, options?)` {/*rendertostring*/} -On the server, call `renderToString` to render your app to HTML. +בשרת, קראו ל-`renderToString` כדי לרנדר את האפליקציה שלכם ל-HTML. ```js import { renderToString } from 'react-dom/server'; @@ -34,34 +34,34 @@ import { renderToString } from 'react-dom/server'; const html = renderToString(); ``` -On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to make the server-generated HTML interactive. +בצד הלקוח, קראו ל-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) כדי להפוך את ה-HTML שנוצר בשרת לאינטראקטיבי. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `reactNode`: A React node you want to render to HTML. For example, a JSX node like ``. +* `reactNode`: React node שברצונכם לרנדר ל-HTML. למשל, JSX node כמו ``. -* **optional** `options`: An object for server render. - * **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters) +* **אופציונלי** `options`: אובייקט עבור רינדור שרת. + * **אופציונלי** `identifierPrefix`: מחרוזת קידומת ש-React משתמשת בה עבור מזהים שנוצרים על ידי [`useId`.](/reference/react/useId) שימושי למניעת התנגשויות כשמשתמשים בכמה roots באותו עמוד. חייב להיות זהה לקידומת שמועברת ל-[`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters) #### Returns {/*returns*/} -An HTML string. +מחרוזת HTML. #### Caveats {/*caveats*/} -* `renderToString` has limited Suspense support. If a component suspends, `renderToString` immediately sends its fallback as HTML. +* ל-`renderToString` יש תמיכה מוגבלת ב-Suspense. אם קומפוננטה מבצעת suspend, `renderToString` שולחת מיד את ה-fallback שלה כ-HTML. -* `renderToString` works in the browser, but using it in the client code is [not recommended.](#removing-rendertostring-from-the-client-code) +* `renderToString` עובדת בדפדפן, אבל שימוש בה בקוד לקוח [לא מומלץ.](#removing-rendertostring-from-the-client-code) --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Rendering a React tree as HTML to a string {/*rendering-a-react-tree-as-html-to-a-string*/} +### רינדור עץ React כ-HTML למחרוזת {/*rendering-a-react-tree-as-html-to-a-string*/} -Call `renderToString` to render your app to an HTML string which you can send with your server response: +קראו ל-`renderToString` כדי לרנדר את האפליקציה שלכם למחרוזת HTML שאפשר לשלוח בתגובת השרת: ```js {5-6} import { renderToString } from 'react-dom/server'; @@ -73,35 +73,35 @@ app.use('/', (request, response) => { }); ``` -This will produce the initial non-interactive HTML output of your React components. On the client, you will need to call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to *hydrate* that server-generated HTML and make it interactive. +כך יתקבל פלט ה-HTML הראשוני הלא אינטראקטיבי של קומפוננטות React שלכם. בצד הלקוח תצטרכו לקרוא ל-[`hydrateRoot`](/reference/react-dom/client/hydrateRoot) כדי לבצע *hydration* ל-HTML שנוצר בשרת ולהפוך אותו לאינטראקטיבי. -`renderToString` does not support streaming or waiting for data. [See the alternatives.](#alternatives) +`renderToString` לא תומכת ב-streaming או בהמתנה לנתונים. [ראו חלופות.](#alternatives) --- -## Alternatives {/*alternatives*/} +## חלופות {/*alternatives*/} -### Migrating from `renderToString` to a streaming method on the server {/*migrating-from-rendertostring-to-a-streaming-method-on-the-server*/} +### מעבר מ-`renderToString` למתודת streaming בצד שרת {/*migrating-from-rendertostring-to-a-streaming-method-on-the-server*/} -`renderToString` returns a string immediately, so it does not support streaming or waiting for data. +`renderToString` מחזירה מחרוזת מיד, ולכן לא תומכת ב-streaming או בהמתנה לנתונים. -When possible, we recommend using these fully-featured alternatives: +כשאפשר, מומלץ להשתמש בחלופות המלאות האלה: -* If you use Node.js, use [`renderToPipeableStream`.](/reference/react-dom/server/renderToPipeableStream) -* If you use Deno or a modern edge runtime with [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), use [`renderToReadableStream`.](/reference/react-dom/server/renderToReadableStream) +* אם אתם משתמשים ב-Node.js, השתמשו ב-[`renderToPipeableStream`.](/reference/react-dom/server/renderToPipeableStream) +* אם אתם משתמשים ב-Deno או runtime מודרני של edge עם [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), השתמשו ב-[`renderToReadableStream`.](/reference/react-dom/server/renderToReadableStream) -You can continue using `renderToString` if your server environment does not support streams. +אפשר להמשיך להשתמש ב-`renderToString` אם סביבת השרת שלכם לא תומכת ב-streams. --- -### Removing `renderToString` from the client code {/*removing-rendertostring-from-the-client-code*/} +### הסרת `renderToString` מקוד לקוח {/*removing-rendertostring-from-the-client-code*/} -Sometimes, `renderToString` is used on the client to convert some component to HTML. +לפעמים `renderToString` משמשת בצד לקוח כדי להמיר קומפוננטה ל-HTML. ```js {1-2} // 🚩 Unnecessary: using renderToString on the client @@ -111,7 +111,7 @@ const html = renderToString(); console.log(html); // For example, "..." ``` -Importing `react-dom/server` **on the client** unnecessarily increases your bundle size and should be avoided. If you need to render some component to HTML in the browser, use [`createRoot`](/reference/react-dom/client/createRoot) and read HTML from the DOM: +ייבוא של `react-dom/server` **בצד לקוח** מגדיל את גודל ה-bundle ללא צורך ויש להימנע ממנו. אם צריך לרנדר קומפוננטה ל-HTML בדפדפן, השתמשו ב-[`createRoot`](/reference/react-dom/client/createRoot) וקראו את ה-HTML מתוך ה-DOM: ```js import { createRoot } from 'react-dom/client'; @@ -125,17 +125,16 @@ flushSync(() => { console.log(div.innerHTML); // For example, "..." ``` -The [`flushSync`](/reference/react-dom/flushSync) call is necessary so that the DOM is updated before reading its [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) property. +הקריאה ל-[`flushSync`](/reference/react-dom/flushSync) נדרשת כדי שה-DOM יתעדכן לפני שקוראים את המאפיין [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML). --- -## Troubleshooting {/*troubleshooting*/} +## פתרון תקלות {/*troubleshooting*/} -### When a component suspends, the HTML always contains a fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/} +### כשקומפוננטה מבצעת suspend, ה-HTML תמיד כולל fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/} -`renderToString` does not fully support Suspense. +`renderToString` לא תומכת באופן מלא ב-Suspense. -If some component suspends (for example, because it's defined with [`lazy`](/reference/react/lazy) or fetches data), `renderToString` will not wait for its content to resolve. Instead, `renderToString` will find the closest [``](/reference/react/Suspense) boundary above it and render its `fallback` prop in the HTML. The content will not appear until the client code loads. - -To solve this, use one of the [recommended streaming solutions.](#migrating-from-rendertostring-to-a-streaming-method-on-the-server) They can stream content in chunks as it resolves on the server so that the user sees the page being progressively filled in before the client code loads. +אם קומפוננטה כלשהי מבצעת suspend (למשל כי היא מוגדרת עם [`lazy`](/reference/react/lazy) או מביאה נתונים), `renderToString` לא תחכה שהתוכן שלה ייפתר. במקום זאת, `renderToString` תמצא את גבול ה-[``](/reference/react/Suspense) הקרוב ביותר מעליה ותרנדר את prop ה-`fallback` שלו בתוך ה-HTML. התוכן לא יופיע עד שטעינת קוד הלקוח תושלם. +כדי לפתור זאת, השתמשו באחד מ-[פתרונות ה-streaming המומלצים.](#migrating-from-rendertostring-to-a-streaming-method-on-the-server) הם יכולים להזרים תוכן במקטעים כשהוא נפתר בשרת, כך שהמשתמש יראה את העמוד מתמלא בהדרגה עוד לפני שקוד הלקוח נטען. diff --git a/src/content/reference/react-dom/unmountComponentAtNode.md b/src/content/reference/react-dom/unmountComponentAtNode.md index 376a9bc2b..f3e9ec9d6 100644 --- a/src/content/reference/react-dom/unmountComponentAtNode.md +++ b/src/content/reference/react-dom/unmountComponentAtNode.md @@ -4,15 +4,15 @@ title: unmountComponentAtNode -This API will be removed in a future major version of React. +ה-API הזה יוסר בגרסה ראשית עתידית של React. -In React 18, `unmountComponentAtNode` was replaced by [`root.unmount()`](/reference/react-dom/client/createRoot#root-unmount). +ב-React 18, `unmountComponentAtNode` הוחלפה ב-[`root.unmount()`](/reference/react-dom/client/createRoot#root-unmount). -`unmountComponentAtNode` removes a mounted React component from the DOM. +`unmountComponentAtNode` מסירה קומפוננטת React שהורכבה מה-DOM. ```js unmountComponentAtNode(domNode) @@ -28,7 +28,7 @@ unmountComponentAtNode(domNode) ### `unmountComponentAtNode(domNode)` {/*unmountcomponentatnode*/} -Call `unmountComponentAtNode` to remove a mounted React component from the DOM and clean up its event handlers and state. +קראו ל-`unmountComponentAtNode` כדי להסיר קומפוננטת React שהורכבה מה-DOM ולנקות את event handlers וה-state שלה. ```js import { unmountComponentAtNode } from 'react-dom'; @@ -39,21 +39,21 @@ render(, domNode); unmountComponentAtNode(domNode); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `domNode`: A [DOM element.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React will remove a mounted React component from this element. +* `domNode`: [אלמנט DOM.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React תסיר ממנו קומפוננטת React שהורכבה. #### Returns {/*returns*/} -`unmountComponentAtNode` returns `true` if a component was unmounted and `false` otherwise. +`unmountComponentAtNode` מחזירה `true` אם קומפוננטה הוסרה ו-`false` אחרת. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -Call `unmountComponentAtNode` to remove a mounted React component from a browser DOM node and clean up its event handlers and state. +קראו ל-`unmountComponentAtNode` כדי להסיר קומפוננטת React שהורכבה מ-DOM node בדפדפן, ולנקות את event handlers וה-state שלה. ```js [[1, 5, ""], [2, 5, "rootNode"], [2, 8, "rootNode"]] import { render, unmountComponentAtNode } from 'react-dom'; @@ -67,11 +67,11 @@ unmountComponentAtNode(rootNode); ``` -### Removing a React app from a DOM element {/*removing-a-react-app-from-a-dom-element*/} +### הסרת אפליקציית React מאלמנט DOM {/*removing-a-react-app-from-a-dom-element*/} -Occasionally, you may want to "sprinkle" React on an existing page, or a page that is not fully written in React. In those cases, you may need to "stop" the React app, by removing all of the UI, state, and listeners from the DOM node it was rendered to. +לעיתים תרצו "לפזר" React בתוך עמוד קיים, או עמוד שלא נכתב כולו ב-React. במקרים כאלה ייתכן שתצטרכו "לעצור" את אפליקציית React, על ידי הסרת כל ה-UI, ה-state וה-listeners מה-DOM node שאליו היא רונדרה. -In this example, clicking "Render React App" will render a React app. Click "Unmount React App" to destroy it: +בדוגמה הזו, לחיצה על "Render React App" תרנדר אפליקציית React. לחצו על "Unmount React App" כדי להשמיד אותה: diff --git a/src/content/reference/react/Fragment.md b/src/content/reference/react/Fragment.md index aa72b08a0..482fa60f7 100644 --- a/src/content/reference/react/Fragment.md +++ b/src/content/reference/react/Fragment.md @@ -4,7 +4,7 @@ title: (<>...) -``, often used via `<>...` syntax, lets you group elements without a wrapper node. +``, שלרוב משתמשים בה דרך התחביר `<>...`, מאפשרת לקבץ אלמנטים בלי node עוטף. ```js <> @@ -23,25 +23,25 @@ title: (<>...) ### `` {/*fragment*/} -Wrap elements in `` to group them together in situations where you need a single element. Grouping elements in `Fragment` has no effect on the resulting DOM; it is the same as if the elements were not grouped. The empty JSX tag `<>` is shorthand for `` in most cases. +עטפו אלמנטים בתוך `` כדי לקבץ אותם במצבים שבהם צריך אלמנט יחיד. קיבוץ אלמנטים בתוך `Fragment` לא משפיע על ה-DOM המתקבל; התוצאה זהה למצב שבו האלמנטים לא קובצו. תגית JSX ריקה `<>` היא קיצור של `` ברוב המקרים. #### Props {/*props*/} -- **optional** `key`: Fragments declared with the explicit `` syntax may have [keys.](/learn/rendering-lists#keeping-list-items-in-order-with-key) +- **אופציונלי** `key`: Fragments שמוצהרים בתחביר מפורש של `` יכולים לקבל [keys.](/learn/rendering-lists#keeping-list-items-in-order-with-key) #### Caveats {/*caveats*/} -- If you want to pass `key` to a Fragment, you can't use the `<>...` syntax. You have to explicitly import `Fragment` from `'react'` and render `...`. +- אם אתם רוצים להעביר `key` ל-Fragment, אי אפשר להשתמש בתחביר `<>...`. צריך לייבא מפורשות את `Fragment` מתוך `'react'` ולרנדר `...`. -- React does not [reset state](/learn/preserving-and-resetting-state) when you go from rendering `<>` to `[]` or back, or when you go from rendering `<>` to `` and back. This only works a single level deep: for example, going from `<><>` to `` resets the state. See the precise semantics [here.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b) +- React לא [מאפסת state](/learn/preserving-and-resetting-state) כשעוברים מרינדור `<>` ל-`[]` או בחזרה, או כשעוברים מרינדור `<>` ל-`` ובחזרה. זה עובד רק לעומק של רמה אחת: למשל, מעבר מ-`<><>` ל-`` כן מאפס את ה-state. אפשר לראות את הסמנטיקה המדויקת [כאן.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b) --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Returning multiple elements {/*returning-multiple-elements*/} +### החזרת כמה אלמנטים {/*returning-multiple-elements*/} -Use `Fragment`, or the equivalent `<>...` syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group: +השתמשו ב-`Fragment`, או בתחביר המקביל `<>...`, כדי לקבץ כמה אלמנטים יחד. אפשר להשתמש בזה כדי לשים כמה אלמנטים בכל מקום שבו אלמנט יחיד יכול להופיע. לדוגמה, קומפוננטה יכולה להחזיר רק אלמנט אחד, אבל בעזרת Fragment אפשר לקבץ כמה אלמנטים ולהחזיר אותם כקבוצה: ```js {3,6} function Post() { @@ -54,7 +54,7 @@ function Post() { } ``` -Fragments are useful because grouping elements with a Fragment has no effect on layout or styles, unlike if you wrapped the elements in another container like a DOM element. If you inspect this example with the browser tools, you'll see that all `

` and `
` DOM nodes appear as siblings without wrappers around them: +Fragments שימושיים כי קיבוץ אלמנטים עם Fragment לא משפיע על layout או styles, בניגוד לעיטוף האלמנטים בתוך מיכל נוסף כמו אלמנט DOM. אם תבדקו את הדוגמה בכלי הדפדפן, תראו שכל ה-DOM nodes של `

` ושל `
` מופיעים כאחים בלי wrappers סביבם: @@ -94,9 +94,9 @@ function PostBody({ body }) { -#### How to write a Fragment without the special syntax? {/*how-to-write-a-fragment-without-the-special-syntax*/} +#### איך לכתוב Fragment בלי התחביר המיוחד? {/*how-to-write-a-fragment-without-the-special-syntax*/} -The example above is equivalent to importing `Fragment` from React: +הדוגמה למעלה שקולה לייבוא `Fragment` מתוך React: ```js {1,5,8} import { Fragment } from 'react'; @@ -111,15 +111,15 @@ function Post() { } ``` -Usually you won't need this unless you need to [pass a `key` to your `Fragment`.](#rendering-a-list-of-fragments) +בדרך כלל לא תצטרכו את זה אלא אם צריך [להעביר `key` ל-`Fragment`.](#rendering-a-list-of-fragments) --- -### Assigning multiple elements to a variable {/*assigning-multiple-elements-to-a-variable*/} +### השמת כמה אלמנטים למשתנה {/*assigning-multiple-elements-to-a-variable*/} -Like any other element, you can assign Fragment elements to variables, pass them as props, and so on: +כמו כל אלמנט אחר, אפשר לשייך Fragment elements למשתנים, להעביר אותם כ-props וכן הלאה: ```js function CloseDialog() { @@ -139,9 +139,9 @@ function CloseDialog() { --- -### Grouping elements with text {/*grouping-elements-with-text*/} +### קיבוץ אלמנטים עם טקסט {/*grouping-elements-with-text*/} -You can use `Fragment` to group text together with components: +אפשר להשתמש ב-`Fragment` כדי לקבץ טקסט יחד עם קומפוננטות: ```js function DateRangePicker({ start, end }) { @@ -158,9 +158,9 @@ function DateRangePicker({ start, end }) { --- -### Rendering a list of Fragments {/*rendering-a-list-of-fragments*/} +### רינדור רשימת Fragments {/*rendering-a-list-of-fragments*/} -Here's a situation where you need to write `Fragment` explicitly instead of using the `<>` syntax. When you [render multiple elements in a loop](/learn/rendering-lists), you need to assign a `key` to each element. If the elements within the loop are Fragments, you need to use the normal JSX element syntax in order to provide the `key` attribute: +זה מצב שבו צריך לכתוב `Fragment` במפורש במקום תחביר `<>`. כש-[מרנדרים כמה אלמנטים בלולאה](/learn/rendering-lists), צריך להקצות `key` לכל אלמנט. אם האלמנטים בלולאה הם Fragments, חייבים להשתמש בתחביר JSX רגיל כדי לספק את המאפיין `key`: ```js {3,6} function Blog() { @@ -173,7 +173,7 @@ function Blog() { } ``` -You can inspect the DOM to verify that there are no wrapper elements around the Fragment children: +אפשר לבדוק ב-DOM שאין אלמנטים עוטפים סביב ילדי ה-Fragment: diff --git a/src/content/reference/react/Profiler.md b/src/content/reference/react/Profiler.md index 502ab0d48..1e25e46ef 100644 --- a/src/content/reference/react/Profiler.md +++ b/src/content/reference/react/Profiler.md @@ -4,7 +4,7 @@ title: -`` lets you measure rendering performance of a React tree programmatically. +`` מאפשר למדוד ביצועי רינדור של עץ React באופן פרוגרמטי. ```js @@ -22,7 +22,7 @@ title: ### `` {/*profiler*/} -Wrap a component tree in a `` to measure its rendering performance. +עטפו עץ קומפוננטות ב-`` כדי למדוד את ביצועי הרינדור שלו. ```js @@ -32,18 +32,18 @@ Wrap a component tree in a `` to measure its rendering performance. #### Props {/*props*/} -* `id`: A string identifying the part of the UI you are measuring. -* `onRender`: An [`onRender` callback](#onrender-callback) that React calls every time components within the profiled tree update. It receives information about what was rendered and how much time it took. +* `id`: מחרוזת שמזהה את החלק ב-UI שאתם מודדים. +* `onRender`: [`onRender` callback](#onrender-callback) ש-React קוראת לו בכל פעם שקומפוננטות בתוך העץ המנוטר מתעדכנות. הוא מקבל מידע על מה רונדר וכמה זמן זה לקח. #### Caveats {/*caveats*/} -* Profiling adds some additional overhead, so **it is disabled in the production build by default.** To opt into production profiling, you need to enable a [special production build with profiling enabled.](https://fb.me/react-profiling) +* Profiling מוסיף מעט overhead, לכן **הוא כבוי כברירת מחדל ב-build של production.** כדי להפעיל profiling ב-production צריך להפעיל [build מיוחד עם profiling פעיל.](https://fb.me/react-profiling) --- ### `onRender` callback {/*onrender-callback*/} -React will call your `onRender` callback with information about what was rendered. +React תקרא ל-`onRender` callback שלכם עם מידע על מה שרונדר. ```js function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime) { @@ -53,20 +53,20 @@ function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime #### Parameters {/*onrender-parameters*/} -* `id`: The string `id` prop of the `` tree that has just committed. This lets you identify which part of the tree was committed if you are using multiple profilers. -* `phase`: `"mount"`, `"update"` or `"nested-update"`. This lets you know whether the tree has just been mounted for the first time or re-rendered due to a change in props, state, or hooks. -* `actualDuration`: The number of milliseconds spent rendering the `` and its descendants for the current update. This indicates how well the subtree makes use of memoization (e.g. [`memo`](/reference/react/memo) and [`useMemo`](/reference/react/useMemo)). Ideally this value should decrease significantly after the initial mount as many of the descendants will only need to re-render if their specific props change. -* `baseDuration`: The number of milliseconds estimating how much time it would take to re-render the entire `` subtree without any optimizations. It is calculated by summing up the most recent render durations of each component in the tree. This value estimates a worst-case cost of rendering (e.g. the initial mount or a tree with no memoization). Compare `actualDuration` against it to see if memoization is working. -* `startTime`: A numeric timestamp for when React began rendering the current update. -* `commitTime`: A numeric timestamp for when React committed the current update. This value is shared between all profilers in a commit, enabling them to be grouped if desirable. +* `id`: מחרוזת ה-`id` prop של עץ ה-`` שבוצע לו commit עכשיו. זה מאפשר לזהות איזה חלק בעץ עבר commit אם אתם משתמשים בכמה profilers. +* `phase`: אחד מהערכים `"mount"`, `"update"` או `"nested-update"`. כך אפשר לדעת האם העץ הורכב עכשיו לראשונה או רונדר מחדש בגלל שינוי ב-props, state או hooks. +* `actualDuration`: מספר המילישניות שהושקעו ברינדור ה-`` וצאצאיו בעדכון הנוכחי. זה מצביע עד כמה תת-העץ משתמש היטב ב-memoization (למשל [`memo`](/reference/react/memo) ו-[`useMemo`](/reference/react/useMemo)). אידיאלית, הערך הזה אמור לרדת משמעותית אחרי ה-mount הראשוני כי רוב הצאצאים יצטרכו לרנדר מחדש רק אם ה-props הרלוונטיים שלהם משתנים. +* `baseDuration`: מספר המילישניות שמעריך כמה זמן היה לוקח לרנדר מחדש את כל תת-העץ של `` בלי אופטימיזציות. הוא מחושב כסכום זמני הרינדור האחרונים של כל קומפוננטה בעץ. הערך הזה מעריך את העלות במקרה הגרוע ביותר של רינדור (למשל mount ראשוני או עץ בלי memoization). השוו אותו ל-`actualDuration` כדי לראות האם memoization עובדת. +* `startTime`: חותמת זמן מספרית לרגע שבו React התחילה לרנדר את העדכון הנוכחי. +* `commitTime`: חותמת זמן מספרית לרגע שבו React ביצעה commit לעדכון הנוכחי. הערך הזה משותף לכל ה-profilers באותו commit, מה שמאפשר לקבץ אותם אם רוצים. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Measuring rendering performance programmatically {/*measuring-rendering-performance-programmatically*/} +### מדידת ביצועי רינדור באופן פרוגרמטי {/*measuring-rendering-performance-programmatically*/} -Wrap the `` component around a React tree to measure its rendering performance. +עטפו את קומפוננטת `` סביב עץ React כדי למדוד את ביצועי הרינדור שלו. ```js {2,4} @@ -77,25 +77,25 @@ Wrap the `` component around a React tree to measure its rendering per ``` -It requires two props: an `id` (string) and an `onRender` callback (function) which React calls any time a component within the tree "commits" an update. +נדרשים שני props: `id` (מחרוזת) ו-`onRender` callback (פונקציה) ש-React קוראת לה בכל פעם שקומפוננטה בתוך העץ מבצעת update עם "commit". -Profiling adds some additional overhead, so **it is disabled in the production build by default.** To opt into production profiling, you need to enable a [special production build with profiling enabled.](https://fb.me/react-profiling) +Profiling מוסיף מעט overhead, לכן **הוא כבוי כברירת מחדל ב-build של production.** כדי להפעיל profiling ב-production צריך להפעיל [build מיוחד עם profiling פעיל.](https://fb.me/react-profiling) -`` lets you gather measurements programmatically. If you're looking for an interactive profiler, try the Profiler tab in [React Developer Tools](/learn/react-developer-tools). It exposes similar functionality as a browser extension. +`` מאפשר לאסוף מדידות באופן פרוגרמטי. אם אתם מחפשים profiler אינטראקטיבי, נסו את לשונית Profiler בתוך [React Developer Tools](/learn/react-developer-tools). היא חושפת יכולות דומות כהרחבת דפדפן. --- -### Measuring different parts of the application {/*measuring-different-parts-of-the-application*/} +### מדידת חלקים שונים באפליקציה {/*measuring-different-parts-of-the-application*/} -You can use multiple `` components to measure different parts of your application: +אפשר להשתמש בכמה קומפוננטות `` כדי למדוד חלקים שונים באפליקציה: ```js {5,7} @@ -108,7 +108,7 @@ You can use multiple `` components to measure different parts of your ``` -You can also nest `` components: +אפשר גם לקנן קומפוננטות ``: ```js {5,7,9,12} @@ -126,7 +126,6 @@ You can also nest `` components: ``` -Although `` is a lightweight component, it should be used only when necessary. Each use adds some CPU and memory overhead to an application. +למרות ש-`` היא קומפוננטה קלת משקל, כדאי להשתמש בה רק כשצריך. כל שימוש מוסיף מעט עומס CPU וזיכרון לאפליקציה. --- - diff --git a/src/content/reference/react/PureComponent.md b/src/content/reference/react/PureComponent.md index 3e2d074e1..9a57a4fd2 100644 --- a/src/content/reference/react/PureComponent.md +++ b/src/content/reference/react/PureComponent.md @@ -4,13 +4,13 @@ title: PureComponent -We recommend defining components as functions instead of classes. [See how to migrate.](#alternatives) +אנחנו ממליצים להגדיר קומפוננטות כפונקציות במקום classes. [ראו איך לבצע מיגרציה.](#alternatives) -`PureComponent` is similar to [`Component`](/reference/react/Component) but it skips re-renders for same props and state. Class components are still supported by React, but we don't recommend using them in new code. +`PureComponent` דומה ל-[`Component`](/reference/react/Component) אבל מדלגת על רינדורים חוזרים עבור אותם props ו-state. קומפוננטות class עדיין נתמכות ב-React, אבל אנחנו לא ממליצים להשתמש בהן בקוד חדש. ```js class Greeting extends PureComponent { @@ -30,7 +30,7 @@ class Greeting extends PureComponent { ### `PureComponent` {/*purecomponent*/} -To skip re-rendering a class component for same props and state, extend `PureComponent` instead of [`Component`:](/reference/react/Component) +כדי לדלג על רינדור חוזר של class component עבור אותם props ו-state, הרחיבו את `PureComponent` במקום את [`Component`:](/reference/react/Component) ```js import { PureComponent } from 'react'; @@ -42,18 +42,18 @@ class Greeting extends PureComponent { } ``` -`PureComponent` is a subclass of `Component` and supports [all the `Component` APIs.](/reference/react/Component#reference) Extending `PureComponent` is equivalent to defining a custom [`shouldComponentUpdate`](/reference/react/Component#shouldcomponentupdate) method that shallowly compares props and state. +`PureComponent` היא תת-מחלקה של `Component` ותומכת [בכל ה-APIs של `Component`.](/reference/react/Component#reference) הרחבה של `PureComponent` שקולה להגדרת מתודת [`shouldComponentUpdate`](/reference/react/Component#shouldcomponentupdate) מותאמת אישית שמשווה shallow את ה-props וה-state. -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Skipping unnecessary re-renders for class components {/*skipping-unnecessary-re-renders-for-class-components*/} +### דילוג על רינדורים חוזרים מיותרים עבור class components {/*skipping-unnecessary-re-renders-for-class-components*/} -React normally re-renders a component whenever its parent re-renders. As an optimization, you can create a component that React will not re-render when its parent re-renders so long as its new props and state are the same as the old props and state. [Class components](/reference/react/Component) can opt into this behavior by extending `PureComponent`: +React בדרך כלל מרנדרת קומפוננטה מחדש בכל פעם שההורה שלה מרונדר מחדש. כאופטימיזציה, אפשר ליצור קומפוננטה ש-React לא תרנדר מחדש כשההורה מרונדר מחדש, כל עוד ה-props וה-state החדשים שלה זהים לישנים. [Class components](/reference/react/Component) יכולות להצטרף להתנהגות הזו על ידי הרחבת `PureComponent`: ```js {1} class Greeting extends PureComponent { @@ -63,9 +63,9 @@ class Greeting extends PureComponent { } ``` -A React component should always have [pure rendering logic.](/learn/keeping-components-pure) This means that it must return the same output if its props, state, and context haven't changed. By using `PureComponent`, you are telling React that your component complies with this requirement, so React doesn't need to re-render as long as its props and state haven't changed. However, your component will still re-render if a context that it's using changes. +לקומפוננטת React תמיד צריכה להיות [לוגיקת רינדור טהורה.](/learn/keeping-components-pure) כלומר, היא חייבת להחזיר את אותו פלט אם ה-props, ה-state וה-context לא השתנו. בשימוש ב-`PureComponent` אתם מצהירים בפני React שהקומפוננטה עומדת בדרישה הזו, לכן React לא צריכה לרנדר מחדש כל עוד ה-props וה-state לא השתנו. עם זאת, הקומפוננטה עדיין תרונדר מחדש אם context שבו היא משתמשת משתנה. -In this example, notice that the `Greeting` component re-renders whenever `name` is changed (because that's one of its props), but not when `address` is changed (because it's not passed to `Greeting` as a prop): +בדוגמה הזו שימו לב שקומפוננטת `Greeting` מרונדרת מחדש בכל פעם ש-`name` משתנה (כי זה אחד ה-props שלה), אבל לא כש-`address` משתנה (כי הוא לא מועבר ל-`Greeting` כ-prop): @@ -109,17 +109,17 @@ label { -We recommend defining components as functions instead of classes. [See how to migrate.](#alternatives) +אנחנו ממליצים להגדיר קומפוננטות כפונקציות במקום classes. [ראו איך לבצע מיגרציה.](#alternatives) --- -## Alternatives {/*alternatives*/} +## חלופות {/*alternatives*/} -### Migrating from a `PureComponent` class component to a function {/*migrating-from-a-purecomponent-class-component-to-a-function*/} +### מיגרציה מ-`PureComponent` class component לפונקציה {/*migrating-from-a-purecomponent-class-component-to-a-function*/} -We recommend using function components instead of [class components](/reference/react/Component) in new code. If you have some existing class components using `PureComponent`, here is how you can convert them. This is the original code: +אנחנו ממליצים להשתמש בקומפוננטות פונקציה במקום [class components](/reference/react/Component) בקוד חדש. אם יש לכם class components קיימות שמשתמשות ב-`PureComponent`, כך אפשר להמיר אותן. זה הקוד המקורי: @@ -161,7 +161,7 @@ label { -When you [convert this component from a class to a function,](/reference/react/Component#alternatives) wrap it in [`memo`:](/reference/react/memo) +כש-[ממירים את הקומפוננטה הזו מ-class לפונקציה,](/reference/react/Component#alternatives) עטפו אותה ב-[`memo`:](/reference/react/memo) @@ -203,6 +203,6 @@ label { -Unlike `PureComponent`, [`memo`](/reference/react/memo) does not compare the new and the old state. In function components, calling the [`set` function](/reference/react/useState#setstate) with the same state [already prevents re-renders by default,](/reference/react/memo#updating-a-memoized-component-using-state) even without `memo`. +בניגוד ל-`PureComponent`, [`memo`](/reference/react/memo) לא משווה בין state חדש לישן. בקומפוננטות פונקציה, קריאה ל-[פונקציית `set`](/reference/react/useState#setstate) עם אותו state [כבר מונעת רינדורים חוזרים כברירת מחדל,](/reference/react/memo#updating-a-memoized-component-using-state) גם בלי `memo`. diff --git a/src/content/reference/react/apis.md b/src/content/reference/react/apis.md index 9c1437870..2ddaed8b9 100644 --- a/src/content/reference/react/apis.md +++ b/src/content/reference/react/apis.md @@ -1,17 +1,17 @@ --- -title: "Built-in React APIs" +title: "React APIs מובנים" --- -In addition to [Hooks](/reference/react) and [Components](/reference/react/components), the `react` package exports a few other APIs that are useful for defining components. This page lists all the remaining modern React APIs. +בנוסף ל-[Hooks](/reference/react) ול-[Components](/reference/react/components), החבילה `react` מייצאת עוד כמה APIs שימושיים להגדרת קומפוננטות. העמוד הזה מפרט את שאר ה-APIs המודרניים של React. --- -* [`createContext`](/reference/react/createContext) lets you define and provide context to the child components. Used with [`useContext`.](/reference/react/useContext) -* [`forwardRef`](/reference/react/forwardRef) lets your component expose a DOM node as a ref to the parent. Used with [`useRef`.](/reference/react/useRef) -* [`lazy`](/reference/react/lazy) lets you defer loading a component's code until it's rendered for the first time. -* [`memo`](/reference/react/memo) lets your component skip re-renders with same props. Used with [`useMemo`](/reference/react/useMemo) and [`useCallback`.](/reference/react/useCallback) -* [`startTransition`](/reference/react/startTransition) lets you mark a state update as non-urgent. Similar to [`useTransition`.](/reference/react/useTransition) +* [`createContext`](/reference/react/createContext) מאפשר להגדיר ולהעביר context לקומפוננטות ילדים. בשימוש יחד עם [`useContext`.](/reference/react/useContext) +* [`forwardRef`](/reference/react/forwardRef) מאפשר לקומפוננטה לחשוף DOM node בתור ref לקומפוננטת הורה. בשימוש יחד עם [`useRef`.](/reference/react/useRef) +* [`lazy`](/reference/react/lazy) מאפשר לדחות את טעינת קוד הקומפוננטה עד לרינדור הראשון שלה. +* [`memo`](/reference/react/memo) מאפשר לקומפוננטה לדלג על רינדורים חוזרים עם אותם props. בשימוש יחד עם [`useMemo`](/reference/react/useMemo) ו-[`useCallback`.](/reference/react/useCallback) +* [`startTransition`](/reference/react/startTransition) מאפשר לסמן עדכון state כלא-דחוף. דומה ל-[`useTransition`.](/reference/react/useTransition) diff --git a/src/content/reference/react/components.md b/src/content/reference/react/components.md index 7ce3fab63..e79e9c92a 100644 --- a/src/content/reference/react/components.md +++ b/src/content/reference/react/components.md @@ -1,24 +1,24 @@ --- -title: "Built-in React Components" +title: "קומפוננטות React מובנות" --- -React exposes a few built-in components that you can use in your JSX. +React חושפת כמה קומפוננטות מובנות שאפשר להשתמש בהן ב-JSX. --- -## Built-in components {/*built-in-components*/} +## קומפוננטות מובנות {/*built-in-components*/} -* [``](/reference/react/Fragment), alternatively written as `<>...`, lets you group multiple JSX nodes together. -* [``](/reference/react/Profiler) lets you measure rendering performance of a React tree programmatically. -* [``](/reference/react/Suspense) lets you display a fallback while the child components are loading. -* [``](/reference/react/StrictMode) enables extra development-only checks that help you find bugs early. +* [``](/reference/react/Fragment), שאפשר לכתוב גם כ-`<>...`, מאפשר לקבץ כמה nodes של JSX יחד. +* [``](/reference/react/Profiler) מאפשר למדוד ביצועי רינדור של עץ React באופן פרוגרמטי. +* [``](/reference/react/Suspense) מאפשר להציג fallback בזמן שקומפוננטות ילדים נטענות. +* [``](/reference/react/StrictMode) מפעיל בדיקות נוספות שתקפות רק בפיתוח ועוזרות למצוא באגים מוקדם. --- -## Your own components {/*your-own-components*/} +## הקומפוננטות שלכם {/*your-own-components*/} -You can also [define your own components](/learn/your-first-component) as JavaScript functions. +אפשר גם [להגדיר קומפוננטות משלכם](/learn/your-first-component) כפונקציות JavaScript. diff --git a/src/content/reference/react/createContext.md b/src/content/reference/react/createContext.md index a653633c1..62f18772b 100644 --- a/src/content/reference/react/createContext.md +++ b/src/content/reference/react/createContext.md @@ -4,7 +4,7 @@ title: createContext -`createContext` lets you create a [context](/learn/passing-data-deeply-with-context) that components can provide or read. +`createContext` מאפשרת ליצור [context](/learn/passing-data-deeply-with-context) שקומפוננטות יכולות לספק או לקרוא. ```js const SomeContext = createContext(defaultValue) @@ -20,7 +20,7 @@ const SomeContext = createContext(defaultValue) ### `createContext(defaultValue)` {/*createcontext*/} -Call `createContext` outside of any components to create a context. +קראו ל-`createContext` מחוץ לכל קומפוננטה כדי ליצור context. ```js import { createContext } from 'react'; @@ -28,26 +28,26 @@ import { createContext } from 'react'; const ThemeContext = createContext('light'); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `defaultValue`: The value that you want the context to have when there is no matching context provider in the tree above the component that reads context. If you don't have any meaningful default value, specify `null`. The default value is meant as a "last resort" fallback. It is static and never changes over time. +* `defaultValue`: הערך שתרצו של-context יהיה כשאין context provider תואם בעץ מעל הקומפוננטה שקוראת את ה-context. אם אין לכם ערך ברירת מחדל משמעותי, ציינו `null`. ערך ברירת המחדל מיועד כ-fallback של "מוצא אחרון". הוא סטטי ולעולם לא משתנה לאורך הזמן. #### Returns {/*returns*/} -`createContext` returns a context object. +`createContext` מחזירה אובייקט context. -**The context object itself does not hold any information.** It represents _which_ context other components read or provide. Typically, you will use [`SomeContext.Provider`](#provider) in components above to specify the context value, and call [`useContext(SomeContext)`](/reference/react/useContext) in components below to read it. The context object has a few properties: +**אובייקט ה-context עצמו לא מחזיק מידע.** הוא מייצג *איזה* context קומפוננטות אחרות קוראות או מספקות. בדרך כלל תשתמשו ב-[`SomeContext.Provider`](#provider) בקומפוננטות למעלה כדי לציין את ערך ה-context, ותקראו ל-[`useContext(SomeContext)`](/reference/react/useContext) בקומפוננטות למטה כדי לקרוא אותו. לאובייקט ה-context יש כמה מאפיינים: -* `SomeContext.Provider` lets you provide the context value to components. -* `SomeContext.Consumer` is an alternative and rarely used way to read the context value. +* `SomeContext.Provider` מאפשר לספק את ערך ה-context לקומפוננטות. +* `SomeContext.Consumer` הוא דרך חלופית ונדירה לקרוא את ערך ה-context. --- ### `SomeContext.Provider` {/*provider*/} -Wrap your components into a context provider to specify the value of this context for all components inside: +עטפו את הקומפוננטות שלכם ב-context provider כדי לציין את ערך ה-context הזה לכל הקומפוננטות בתוכו: ```js function App() { @@ -63,13 +63,13 @@ function App() { #### Props {/*provider-props*/} -* `value`: The value that you want to pass to all the components reading this context inside this provider, no matter how deep. The context value can be of any type. A component calling [`useContext(SomeContext)`](/reference/react/useContext) inside of the provider receives the `value` of the innermost corresponding context provider above it. +* `value`: הערך שברצונכם להעביר לכל הקומפוננטות שקוראות את ה-context הזה בתוך ה-provider הזה, לא משנה כמה עמוק. ערך ה-context יכול להיות מכל סוג. קומפוננטה שקוראת ל-[`useContext(SomeContext)`](/reference/react/useContext) בתוך ה-provider תקבל את ה-`value` של ה-context provider התואם הפנימי ביותר שמעליה. --- ### `SomeContext.Consumer` {/*consumer*/} -Before `useContext` existed, there was an older way to read context: +לפני ש-`useContext` הייתה קיימת, הייתה דרך ישנה יותר לקרוא context: ```js function Button() { @@ -84,7 +84,7 @@ function Button() { } ``` -Although this older way still works, but **newly written code should read context with [`useContext()`](/reference/react/useContext) instead:** +למרות שהדרך הישנה הזו עדיין עובדת, **קוד חדש צריך לקרוא context בעזרת [`useContext()`](/reference/react/useContext) במקום:** ```js function Button() { @@ -96,17 +96,17 @@ function Button() { #### Props {/*consumer-props*/} -* `children`: A function. React will call the function you pass with the current context value determined by the same algorithm as [`useContext()`](/reference/react/useContext) does, and render the result you return from this function. React will also re-run this function and update the UI whenever the context from the parent components changes. +* `children`: פונקציה. React תקרא לפונקציה שתעבירו עם ערך ה-context הנוכחי שנקבע על ידי אותו אלגוריתם שבו משתמשת [`useContext()`](/reference/react/useContext), ותרנדר את התוצאה שתחזירו מהפונקציה הזו. React גם תריץ את הפונקציה הזו שוב ותעדכן את ה-UI בכל פעם שה-context מהקומפוננטות ההורה משתנה. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Creating context {/*creating-context*/} +### יצירת context {/*creating-context*/} -Context lets components [pass information deep down](/learn/passing-data-deeply-with-context) without explicitly passing props. +Context מאפשר לקומפוננטות [להעביר מידע עמוק יותר בעץ](/learn/passing-data-deeply-with-context) בלי להעביר props במפורש. -Call `createContext` outside any components to create one or more contexts. +קראו ל-`createContext` מחוץ לכל קומפוננטה כדי ליצור context אחד או יותר. ```js [[1, 3, "ThemeContext"], [1, 4, "AuthContext"], [3, 3, "'light'"], [3, 4, "null"]] import { createContext } from 'react'; @@ -115,7 +115,7 @@ const ThemeContext = createContext('light'); const AuthContext = createContext(null); ``` -`createContext` returns a context object. Components can read context by passing it to [`useContext()`](/reference/react/useContext): +`createContext` מחזירה אובייקט context. קומפוננטות יכולות לקרוא context על ידי העברתו ל-[`useContext()`](/reference/react/useContext): ```js [[1, 2, "ThemeContext"], [1, 7, "AuthContext"]] function Button() { @@ -129,9 +129,9 @@ function Profile() { } ``` -By default, the values they receive will be the default values you have specified when creating the contexts. However, by itself this isn't useful because the default values never change. +כברירת מחדל, הערכים שהן יקבלו יהיו ערכי ברירת המחדל שציינתם בעת יצירת ה-context. אבל בפני עצמו זה לא שימושי, כי ערכי ברירת המחדל לעולם לא משתנים. -Context is useful because you can **provide other, dynamic values from your components:** +Context שימושי כי אפשר **לספק ערכים אחרים, דינמיים, מתוך הקומפוננטות שלכם:** ```js {8-9,11-12} function App() { @@ -150,15 +150,15 @@ function App() { } ``` -Now the `Page` component and any components inside it, no matter how deep, will "see" the passed context values. If the passed context values change, React will re-render the components reading the context as well. +עכשיו קומפוננטת `Page` וכל קומפוננטה בתוכה, לא משנה כמה עמוק, "יראו" את ערכי ה-context שהועברו. אם ערכי ה-context משתנים, React תרנדר מחדש גם את הקומפוננטות שקוראות את ה-context. -[Read more about reading and providing context and see examples.](/reference/react/useContext) +[קראו עוד על קריאה וסיפוק context וראו דוגמאות.](/reference/react/useContext) --- -### Importing and exporting context from a file {/*importing-and-exporting-context-from-a-file*/} +### ייבוא וייצוא context מקובץ {/*importing-and-exporting-context-from-a-file*/} -Often, components in different files will need access to the same context. This is why it's common to declare contexts in a separate file. Then you can use the [`export` statement](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) to make context available for other files: +לעיתים קרובות קומפוננטות בקבצים שונים צריכות גישה לאותו context. לכן מקובל להצהיר על contexts בקובץ נפרד. לאחר מכן אפשר להשתמש ב-[`export` statement](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) כדי להפוך את ה-context לזמין לקבצים אחרים: ```js {4-5} // Contexts.js @@ -168,7 +168,7 @@ export const ThemeContext = createContext('light'); export const AuthContext = createContext(null); ``` -Components declared in other files can then use the [`import`](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import) statement to read or provide this context: +קומפוננטות שמוצהרות בקבצים אחרים יכולות להשתמש ב-[`import`](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import) כדי לקרוא או לספק את ה-context הזה: ```js {2} // Button.js @@ -196,22 +196,21 @@ function App() { } ``` -This works similar to [importing and exporting components.](/learn/importing-and-exporting-components) +זה עובד בדומה ל-[ייבוא וייצוא קומפוננטות.](/learn/importing-and-exporting-components) --- -## Troubleshooting {/*troubleshooting*/} +## פתרון תקלות {/*troubleshooting*/} -### I can't find a way to change the context value {/*i-cant-find-a-way-to-change-the-context-value*/} +### אני לא מוצא דרך לשנות את ערך ה-context {/*i-cant-find-a-way-to-change-the-context-value*/} -Code like this specifies the *default* context value: +קוד כזה מציין את ערך ה-context *ברירת המחדל*: ```js const ThemeContext = createContext('light'); ``` -This value never changes. React only uses this value as a fallback if it can't find a matching provider above. - -To make context change over time, [add state and wrap components in a context provider.](/reference/react/useContext#updating-data-passed-via-context) +הערך הזה לעולם לא משתנה. React משתמשת בו רק כ-fallback אם היא לא מוצאת provider תואם מעל. +כדי לגרום ל-context להשתנות לאורך הזמן, [הוסיפו state ועטפו קומפוננטות ב-context provider.](/reference/react/useContext#updating-data-passed-via-context) diff --git a/src/content/reference/react/createElement.md b/src/content/reference/react/createElement.md index a5f684c66..91c92077a 100644 --- a/src/content/reference/react/createElement.md +++ b/src/content/reference/react/createElement.md @@ -4,7 +4,7 @@ title: createElement -`createElement` lets you create a React element. It serves as an alternative to writing [JSX.](/learn/writing-markup-with-jsx) +`createElement` מאפשרת ליצור React element. היא משמשת חלופה לכתיבת [JSX.](/learn/writing-markup-with-jsx) ```js const element = createElement(type, props, ...children) @@ -20,7 +20,7 @@ const element = createElement(type, props, ...children) ### `createElement(type, props, ...children)` {/*createelement*/} -Call `createElement` to create a React element with the given `type`, `props`, and `children`. +קראו ל-`createElement` כדי ליצור React element עם `type`, `props` ו-`children` נתונים. ```js import { createElement } from 'react'; @@ -34,46 +34,46 @@ function Greeting({ name }) { } ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)). +* `type`: הארגומנט `type` חייב להיות סוג קומפוננטת React תקין. למשל, מחרוזת שם תגית (כמו `'div'` או `'span'`), או קומפוננטת React (פונקציה, class, או קומפוננטה מיוחדת כמו [`Fragment`](/reference/react/Fragment)). -* `props`: The `props` argument must either be an object or `null`. If you pass `null`, it will be treated the same as an empty object. React will create an element with props matching the `props` you have passed. Note that `ref` and `key` from your `props` object are special and will *not* be available as `element.props.ref` and `element.props.key` on the returned `element`. They will be available as `element.ref` and `element.key`. +* `props`: הארגומנט `props` חייב להיות אובייקט או `null`. אם תעבירו `null`, הוא יטופל כמו אובייקט ריק. React תיצור element עם props תואמים ל-`props` שהעברתם. שימו לב ש-`ref` ו-`key` מתוך אובייקט ה-`props` שלכם הם מיוחדים, ולכן *לא* יהיו זמינים כ-`element.props.ref` ו-`element.props.key` על ה-`element` המוחזר. הם יהיו זמינים כ-`element.ref` ו-`element.key`. -* **optional** `...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes. +* **אופציונלי** `...children`: אפס או יותר child nodes. הם יכולים להיות כל סוג של React nodes, כולל React elements, מחרוזות, מספרים, [portals](/reference/react-dom/createPortal), nodes ריקים (`null`, `undefined`, `true`, ו-`false`), ומערכים של React nodes. #### Returns {/*returns*/} -`createElement` returns a React element object with a few properties: +`createElement` מחזירה אובייקט React element עם כמה מאפיינים: -* `type`: The `type` you have passed. -* `props`: The `props` you have passed except for `ref` and `key`. If the `type` is a component with legacy `type.defaultProps`, then any missing or undefined `props` will get the values from `type.defaultProps`. -* `ref`: The `ref` you have passed. If missing, `null`. -* `key`: The `key` you have passed, coerced to a string. If missing, `null`. +* `type`: ה-`type` שהעברתם. +* `props`: ה-`props` שהעברתם, למעט `ref` ו-`key`. אם `type` היא קומפוננטה עם legacy `type.defaultProps`, אז כל `props` חסרים או `undefined` יקבלו את הערכים מתוך `type.defaultProps`. +* `ref`: ה-`ref` שהעברתם. אם חסר, `null`. +* `key`: ה-`key` שהעברתם, מומר למחרוזת. אם חסר, `null`. -Usually, you'll return the element from your component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it. +בדרך כלל תחזירו את ה-element מהקומפוננטה שלכם או תהפכו אותו ל-child של element אחר. למרות שאפשר לקרוא את מאפייני ה-element, עדיף להתייחס לכל element כלא שקוף אחרי יצירתו ורק לרנדר אותו. #### Caveats {/*caveats*/} -* You must **treat React elements and their props as [immutable](https://en.wikipedia.org/wiki/Immutable_object)** and never change their contents after creation. In development, React will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) the returned element and its `props` property shallowly to enforce this. +* צריך **להתייחס ל-React elements ול-props שלהם כ-[immutable](https://en.wikipedia.org/wiki/Immutable_object)** ולעולם לא לשנות את התוכן שלהם אחרי יצירה. בזמן פיתוח, React תבצע [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) רדוד ל-element המוחזר ולמאפיין `props` שלו כדי לאכוף זאת. -* When you use JSX, **you must start a tag with a capital letter to render your own custom component.** In other words, `` is equivalent to `createElement(Something)`, but `` (lowercase) is equivalent to `createElement('something')` (note it's a string, so it will be treated as a built-in HTML tag). +* כשמשתמשים ב-JSX, **חייבים להתחיל תגית באות גדולה כדי לרנדר custom component.** כלומר, `` שקול ל-`createElement(Something)`, אבל `` (אותיות קטנות) שקול ל-`createElement('something')` (שימו לב שזו מחרוזת, ולכן תטופל כתגית HTML מובנית). -* You should only **pass children as multiple arguments to `createElement` if they are all statically known,** like `createElement('h1', {}, child1, child2, child3)`. If your children are dynamic, pass the entire array as the third argument: `createElement('ul', {}, listItems)`. This ensures that React will [warn you about missing `key`s](/learn/rendering-lists#keeping-list-items-in-order-with-key) for any dynamic lists. For static lists this is not necessary because they never reorder. +* כדאי **להעביר children כארגומנטים מרובים ל-`createElement` רק אם כולם ידועים סטטית,** כמו `createElement('h1', {}, child1, child2, child3)`. אם הילדים דינמיים, העבירו את כל המערך כארגומנט שלישי: `createElement('ul', {}, listItems)`. כך React תוכל [להזהיר על `key`s חסרים](/learn/rendering-lists#keeping-list-items-in-order-with-key) עבור רשימות דינמיות. לרשימות סטטיות אין צורך בכך כי הן לא משנות סדר. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Creating an element without JSX {/*creating-an-element-without-jsx*/} +### יצירת element בלי JSX {/*creating-an-element-without-jsx*/} -If you don't like [JSX](/learn/writing-markup-with-jsx) or can't use it in your project, you can use `createElement` as an alternative. +אם אתם לא אוהבים [JSX](/learn/writing-markup-with-jsx) או לא יכולים להשתמש בה בפרויקט, אפשר להשתמש ב-`createElement` כחלופה. -To create an element without JSX, call `createElement` with some type, props, and children: +כדי ליצור element בלי JSX, קראו ל-`createElement` עם type, props, ו-children: -```js [[1, 5, "'h1'"], [2, 6, "{ className: 'greeting' }"], [3, 7, "'Hello ',"], [3, 8, "createElement('i', null, name),"], [3, 9, "'. Welcome!'"]] +```js import { createElement } from 'react'; function Greeting({ name }) { @@ -87,9 +87,9 @@ function Greeting({ name }) { } ``` -The children are optional, and you can pass as many as you need (the example above has three children). This code will display a `

` header with a greeting. For comparison, here is the same example rewritten with JSX: +ה-children אופציונליים, ואפשר להעביר כמה שצריך (בדוגמה למעלה יש שלושה children). הקוד הזה יציג כותרת `

` עם ברכה. להשוואה, הנה אותה דוגמה שנכתבה עם JSX: -```js [[1, 3, "h1"], [2, 3, "className=\\"greeting\\""], [3, 4, "Hello {name}. Welcome!"], [1, 5, "h1"]] +```js function Greeting({ name }) { return (

@@ -99,23 +99,23 @@ function Greeting({ name }) { } ``` -To render your own React component, pass a function like `Greeting` as the type instead of a string like `'h1'`: +כדי לרנדר קומפוננטת React משלכם, העבירו פונקציה כמו `Greeting` כ-type במקום מחרוזת כמו `'h1'`: -```js [[1, 2, "Greeting"], [2, 2, "{ name: 'Taylor' }"]] +```js export default function App() { return createElement(Greeting, { name: 'Taylor' }); } ``` -With JSX, it would look like this: +עם JSX זה היה נראה כך: -```js [[1, 2, "Greeting"], [2, 2, "name=\\"Taylor\\""]] +```js export default function App() { return ; } ``` -Here is a complete example written with `createElement`: +הנה דוגמה מלאה שנכתבה עם `createElement`: @@ -149,7 +149,7 @@ export default function App() { -And here is the same example written using JSX: +והנה אותה דוגמה כשהיא כתובה עם JSX: @@ -176,13 +176,13 @@ export default function App() { -Both coding styles are fine, so you can use whichever one you prefer for your project. The main benefit of using JSX compared to `createElement` is that it's easy to see which closing tag corresponds to which opening tag. +שני סגנונות הקוד תקינים, ואפשר להשתמש במה שמתאים לפרויקט שלכם. היתרון המרכזי של JSX לעומת `createElement` הוא שקל לראות איזו תגית סוגרת שייכת לאיזו תגית פותחת. -#### What is a React element, exactly? {/*what-is-a-react-element-exactly*/} +#### מהו בעצם React element? {/*what-is-a-react-element-exactly*/} -An element is a lightweight description of a piece of the user interface. For example, both `` and `createElement(Greeting, { name: 'Taylor' })` produce an object like this: +Element הוא תיאור קל משקל של חלק מממשק המשתמש. למשל, גם `` וגם `createElement(Greeting, { name: 'Taylor' })` מייצרים אובייקט כזה: ```js // Slightly simplified @@ -196,10 +196,10 @@ An element is a lightweight description of a piece of the user interface. For ex } ``` -**Note that creating this object does not render the `Greeting` component or create any DOM elements.** +**שימו לב שיצירת האובייקט הזה לא מרנדרת את הקומפוננטה `Greeting` ולא יוצרת אלמנטים ב-DOM.** -A React element is more like a description--an instruction for React to later render the `Greeting` component. By returning this object from your `App` component, you tell React what to do next. +React element דומה יותר לתיאור - הוראה ל-React לרנדר מאוחר יותר את הקומפוננטה `Greeting`. על ידי החזרת האובייקט הזה מקומפוננטת `App`, אתם אומרים ל-React מה לעשות בהמשך. -Creating elements is extremely cheap so you don't need to try to optimize or avoid it. +יצירת elements היא פעולה זולה מאוד, כך שאין צורך לנסות לבצע לה אופטימיזציה או להימנע ממנה. diff --git a/src/content/reference/react/createFactory.md b/src/content/reference/react/createFactory.md index 7df7fcd87..751d8923d 100644 --- a/src/content/reference/react/createFactory.md +++ b/src/content/reference/react/createFactory.md @@ -4,13 +4,13 @@ title: createFactory -This API will be removed in a future major version of React. [See the alternatives.](#alternatives) +ה-API הזה יוסר בגרסה ראשית עתידית של React. [ראו חלופות.](#alternatives) -`createFactory` lets you create a function that produces React elements of a given type. +`createFactory` מאפשרת ליצור פונקציה שמייצרת React elements מסוג נתון. ```js const factory = createFactory(type) @@ -26,7 +26,7 @@ const factory = createFactory(type) ### `createFactory(type)` {/*createfactory*/} -Call `createFactory(type)` to create a factory function which produces React elements of a given `type`. +קראו ל-`createFactory(type)` כדי ליצור פונקציית factory שמייצרת React elements מסוג `type` נתון. ```js import { createFactory } from 'react'; @@ -34,7 +34,7 @@ import { createFactory } from 'react'; const button = createFactory('button'); ``` -Then you can use it to create React elements without JSX: +ואז אפשר להשתמש בה כדי ליצור React elements בלי JSX: ```js export default function App() { @@ -46,25 +46,25 @@ export default function App() { } ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)). +* `type`: הארגומנט `type` חייב להיות סוג קומפוננטת React תקין. למשל, מחרוזת שם תגית (כמו `'div'` או `'span'`), או קומפוננטת React (פונקציה, מחלקה, או קומפוננטה מיוחדת כמו [`Fragment`](/reference/react/Fragment)). #### Returns {/*returns*/} -Returns a factory function. That factory function receives a `props` object as the first argument, followed by a list of `...children` arguments, and returns a React element with the given `type`, `props` and `children`. +מחזירה פונקציית factory. פונקציית ה-factory הזו מקבלת אובייקט `props` כארגומנט ראשון, אחריו רשימת ארגומנטים `...children`, ומחזירה React element עם ה-`type`, ה-`props` וה-`children` הנתונים. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Creating React elements with a factory {/*creating-react-elements-with-a-factory*/} +### יצירת React elements עם factory {/*creating-react-elements-with-a-factory*/} -Although most React projects use [JSX](/learn/writing-markup-with-jsx) to describe the user interface, JSX is not required. In the past, `createFactory` used to be one of the ways you could describe the user interface without JSX. +למרות שרוב פרויקטי React משתמשים ב-[JSX](/learn/writing-markup-with-jsx) כדי לתאר את ממשק המשתמש, JSX אינה חובה. בעבר, `createFactory` הייתה אחת הדרכים לתאר ממשק משתמש בלי JSX. -Call `createFactory` to create a *factory function* for a specific element type like `'button'`: +קראו ל-`createFactory` כדי ליצור *פונקציית factory* עבור סוג אלמנט מסוים כמו `'button'`: ```js import { createFactory } from 'react'; @@ -72,7 +72,7 @@ import { createFactory } from 'react'; const button = createFactory('button'); ``` -Calling that factory function will produce React elements with the props and children you have provided: +קריאה לפונקציית ה-factory הזו תייצר React elements עם ה-props וה-children שסיפקתם: @@ -92,15 +92,15 @@ export default function App() { -This is how `createFactory` was used as an alternative to JSX. However, `createFactory` is deprecated, and you should not call `createFactory` in any new code. See how to migrate away from `createFactory` below. +כך השתמשו ב-`createFactory` כחלופה ל-JSX. אבל `createFactory` הוצאה משימוש, ולא כדאי לקרוא לה בקוד חדש. ראו בהמשך איך לבצע מיגרציה מ-`createFactory`. --- -## Alternatives {/*alternatives*/} +## חלופות {/*alternatives*/} -### Copying `createFactory` into your project {/*copying-createfactory-into-your-project*/} +### העתקת `createFactory` לתוך הפרויקט שלכם {/*copying-createfactory-into-your-project*/} -If your project has many `createFactory` calls, copy this `createFactory.js` implementation into your project: +אם בפרויקט שלכם יש הרבה קריאות ל-`createFactory`, העתיקו את המימוש הבא של `createFactory.js` לתוך הפרויקט: @@ -128,13 +128,13 @@ export function createFactory(type) { -This lets you keep all of your code unchanged except the imports. +כך אפשר להשאיר את כל הקוד ללא שינוי מלבד הייבואים. --- -### Replacing `createFactory` with `createElement` {/*replacing-createfactory-with-createelement*/} +### החלפת `createFactory` ב-`createElement` {/*replacing-createfactory-with-createelement*/} -If you have a few `createFactory` calls that you don't mind porting manually, and you don't want to use JSX, you can replace every call a factory function with a [`createElement`](/reference/react/createElement) call. For example, you can replace this code: +אם יש לכם מעט קריאות ל-`createFactory` ואתם לא מתנגדים לבצע המרה ידנית, ואתם לא רוצים להשתמש ב-JSX, אפשר להחליף כל קריאה לפונקציית factory בקריאה ל-[`createElement`](/reference/react/createElement). למשל, אפשר להחליף את הקוד הזה: ```js {1,3,6} import { createFactory } from 'react'; @@ -150,7 +150,7 @@ export default function App() { } ``` -with this code: +בקוד הזה: ```js {1,4} @@ -165,7 +165,7 @@ export default function App() { } ``` -Here is a complete example of using React without JSX: +הנה דוגמה מלאה לשימוש ב-React ללא JSX: @@ -185,9 +185,9 @@ export default function App() { --- -### Replacing `createFactory` with JSX {/*replacing-createfactory-with-jsx*/} +### החלפת `createFactory` ב-JSX {/*replacing-createfactory-with-jsx*/} -Finally, you can use JSX instead of `createFactory`. This is the most common way to use React: +לבסוף, אפשר להשתמש ב-JSX במקום `createFactory`. זו הדרך הנפוצה ביותר להשתמש ב-React: @@ -207,7 +207,7 @@ export default function App() { -Sometimes, your existing code might pass some variable as a `type` instead of a constant like `'button'`: +לפעמים קוד קיים עשוי להעביר משתנה כלשהו כ-`type` במקום קבוע כמו `'button'`: ```js {3} function Heading({ isSubheading, ...props }) { @@ -217,7 +217,7 @@ function Heading({ isSubheading, ...props }) { } ``` -To do the same in JSX, you need to rename your variable to start with an uppercase letter like `Type`: +כדי לעשות את אותו הדבר ב-JSX, צריך לשנות את שם המשתנה כדי שיתחיל באות גדולה, למשל `Type`: ```js {2,3} function Heading({ isSubheading, ...props }) { @@ -226,6 +226,6 @@ function Heading({ isSubheading, ...props }) { } ``` -Otherwise React will interpret `` as a built-in HTML tag because it is lowercase. +אחרת React תפרש `` כתגית HTML מובנית כי היא באותיות קטנות. diff --git a/src/content/reference/react/createRef.md b/src/content/reference/react/createRef.md index 2a3ba6aa3..fdc4df16a 100644 --- a/src/content/reference/react/createRef.md +++ b/src/content/reference/react/createRef.md @@ -4,13 +4,13 @@ title: createRef -`createRef` is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef) instead. +`createRef` בשימוש בעיקר עבור [class components.](/reference/react/Component) קומפוננטות פונקציה בדרך כלל נשענות על [`useRef`](/reference/react/useRef) במקום. -`createRef` creates a [ref](/learn/referencing-values-with-refs) object which can contain arbitrary value. +`createRef` יוצרת אובייקט [ref](/learn/referencing-values-with-refs) שיכול להכיל כל ערך. ```js class MyInput extends Component { @@ -29,7 +29,7 @@ class MyInput extends Component { ### `createRef()` {/*createref*/} -Call `createRef` to declare a [ref](/learn/referencing-values-with-refs) inside a [class component.](/reference/react/Component) +קראו ל-`createRef` כדי להצהיר על [ref](/learn/referencing-values-with-refs) בתוך [class component.](/reference/react/Component) ```js import { createRef, Component } from 'react'; @@ -40,31 +40,31 @@ class MyComponent extends Component { // ... ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -`createRef` takes no parameters. +`createRef` לא מקבלת פרמטרים. #### Returns {/*returns*/} -`createRef` returns an object with a single property: +`createRef` מחזירה אובייקט עם מאפיין יחיד: -* `current`: Initially, it's set to the `null`. You can later set it to something else. If you pass the ref object to React as a `ref` attribute to a JSX node, React will set its `current` property. +* `current`: בתחילה מוגדר ל-`null`. לאחר מכן אפשר להגדיר אותו לערך אחר. אם מעבירים את אובייקט ה-ref ל-React כמאפיין `ref` ל-JSX node, React תגדיר את המאפיין `current` שלו. #### Caveats {/*caveats*/} -* `createRef` always returns a *different* object. It's equivalent to writing `{ current: null }` yourself. -* In a function component, you probably want [`useRef`](/reference/react/useRef) instead which always returns the same object. -* `const ref = useRef()` is equivalent to `const [ref, _] = useState(() => createRef(null))`. +* `createRef` תמיד מחזירה אובייקט *שונה*. זה שקול לכתיבה ידנית של `{ current: null }`. +* בקומפוננטת פונקציה, כנראה שתרצו [`useRef`](/reference/react/useRef), שמחזירה תמיד את אותו אובייקט. +* `const ref = useRef()` שקול ל-`const [ref, _] = useState(() => createRef(null))`. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Declaring a ref in a class component {/*declaring-a-ref-in-a-class-component*/} +### הצהרה על ref בתוך class component {/*declaring-a-ref-in-a-class-component*/} -To declare a ref inside a [class component,](/reference/react/Component) call `createRef` and assign its result to a class field: +כדי להצהיר על ref בתוך [class component,](/reference/react/Component) קראו ל-`createRef` והקצו את התוצאה לשדה במחלקה: ```js {4} import { Component, createRef } from 'react'; @@ -76,7 +76,7 @@ class Form extends Component { } ``` -If you now pass `ref={this.inputRef}` to an `` in your JSX, React will populate `this.inputRef.current` with the input DOM node. For example, here is how you make a button that focuses the input: +אם תעבירו כעת `ref={this.inputRef}` ל-`` ב-JSX שלכם, React תאכלס את `this.inputRef.current` עם DOM node של שדה הקלט. למשל, כך יוצרים כפתור שמפקס את שדה הקלט: @@ -107,17 +107,17 @@ export default class Form extends Component { -`createRef` is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef) instead. +`createRef` בשימוש בעיקר עבור [class components.](/reference/react/Component) קומפוננטות פונקציה בדרך כלל נשענות על [`useRef`](/reference/react/useRef) במקום. --- -## Alternatives {/*alternatives*/} +## חלופות {/*alternatives*/} -### Migrating from a class with `createRef` to a function with `useRef` {/*migrating-from-a-class-with-createref-to-a-function-with-useref*/} +### מעבר מ-class עם `createRef` לפונקציה עם `useRef` {/*migrating-from-a-class-with-createref-to-a-function-with-useref*/} -We recommend using function components instead of [class components](/reference/react/Component) in new code. If you have some existing class components using `createRef`, here is how you can convert them. This is the original code: +אנחנו ממליצים להשתמש בקומפוננטות פונקציה במקום [class components](/reference/react/Component) בקוד חדש. אם יש לכם class components קיימות שמשתמשות ב-`createRef`, כך אפשר להמיר אותן. זה הקוד המקורי: @@ -146,7 +146,7 @@ export default class Form extends Component { -When you [convert this component from a class to a function,](/reference/react/Component#alternatives) replace calls to `createRef` with calls to [`useRef`:](/reference/react/useRef) +כש-[ממירים את הקומפוננטה הזו מ-class לפונקציה,](/reference/react/Component#alternatives) מחליפים קריאות ל-`createRef` בקריאות ל-[`useRef`:](/reference/react/useRef) diff --git a/src/content/reference/react/directives.md b/src/content/reference/react/directives.md index 4854310b3..21d5c19a4 100644 --- a/src/content/reference/react/directives.md +++ b/src/content/reference/react/directives.md @@ -5,19 +5,19 @@ canary: true -These directives are needed only if you're [using React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) or building a library compatible with them. +ה-directives האלה נדרשים רק אם אתם [משתמשים ב-React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) או בונים ספרייה שתואמת אליהם. -Directives provide instructions to [bundlers compatible with React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks). +Directives מספקים הנחיות ל-[bundlers שתואמים ל-React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks). --- -## Source code directives {/*source-code-directives*/} +## Directives בקוד מקור {/*source-code-directives*/} -* [`'use client'`](/reference/react/use-client) lets you mark what code runs on the client. -* [`'use server'`](/reference/react/use-server) marks server-side functions that can be called from client-side code. \ No newline at end of file +* [`'use client'`](/reference/react/use-client) מאפשר לסמן איזה קוד רץ בצד לקוח. +* [`'use server'`](/reference/react/use-server) מסמן פונקציות צד שרת שאפשר לקרוא להן מקוד צד לקוח. diff --git a/src/content/reference/react/experimental_taintObjectReference.md b/src/content/reference/react/experimental_taintObjectReference.md index b5b9e513d..40a962896 100644 --- a/src/content/reference/react/experimental_taintObjectReference.md +++ b/src/content/reference/react/experimental_taintObjectReference.md @@ -4,30 +4,30 @@ title: experimental_taintObjectReference -**This API is experimental and is not available in a stable version of React yet.** +**ה-API הזה ניסיוני ועדיין לא זמין בגרסה יציבה של React.** -You can try it by upgrading React packages to the most recent experimental version: +אפשר לנסות אותו על ידי שדרוג חבילות React לגרסה הניסיונית העדכנית ביותר: - `react@experimental` - `react-dom@experimental` - `eslint-plugin-react-hooks@experimental` -Experimental versions of React may contain bugs. Don't use them in production. +גרסאות ניסיוניות של React עשויות להכיל באגים. אל תשתמשו בהן ב-production. -This API is only available inside React Server Components. +ה-API הזה זמין רק בתוך React Server Components. -`taintObjectReference` lets you prevent a specific object instance from being passed to a Client Component like a `user` object. +`taintObjectReference` מאפשרת למנוע העברה של מופע אובייקט ספציפי ל-Client Component, כמו אובייקט `user`. ```js experimental_taintObjectReference(message, object); ``` -To prevent passing a key, hash or token, see [`taintUniqueValue`](/reference/react/experimental_taintUniqueValue). +כדי למנוע העברה של מפתח, hash או token, ראו [`taintUniqueValue`](/reference/react/experimental_taintUniqueValue). @@ -39,7 +39,7 @@ To prevent passing a key, hash or token, see [`taintUniqueValue`](/reference/rea ### `taintObjectReference(message, object)` {/*taintobjectreference*/} -Call `taintObjectReference` with an object to register it with React as something that should not be allowed to be passed to the Client as is: +קראו ל-`taintObjectReference` עם אובייקט כדי לרשום אותו ב-React כמשהו שאסור להעביר ללקוח כפי שהוא: ```js import {experimental_taintObjectReference} from 'react'; @@ -50,35 +50,35 @@ experimental_taintObjectReference( ); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `message`: The message you want to display if the object gets passed to a Client Component. This message will be displayed as a part of the Error that will be thrown if the object gets passed to a Client Component. +* `message`: ההודעה שתרצו להציג אם האובייקט יועבר ל-Client Component. ההודעה הזו תוצג כחלק מה-Error שיושלך אם האובייקט יועבר ל-Client Component. -* `object`: The object to be tainted. Functions and class instances can be passed to `taintObjectReference` as `object`. Functions and classes are already blocked from being passed to Client Components but the React's default error message will be replaced by what you defined in `message`. When a specific instance of a Typed Array is passed to `taintObjectReference` as `object`, any other copies of the Typed Array will not be tainted. +* `object`: האובייקט שיסומן כ-tainted. אפשר להעביר פונקציות ומופעי מחלקות ל-`taintObjectReference` כ-`object`. פונקציות ומחלקות כבר חסומות להעברה ל-Client Components, אבל הודעת השגיאה ברירת המחדל של React תוחלף במה שהגדרתם ב-`message`. כאשר מופע ספציפי של Typed Array מועבר ל-`taintObjectReference` כ-`object`, עותקים אחרים של אותה Typed Array לא יסומנו כ-tainted. #### Returns {/*returns*/} -`experimental_taintObjectReference` returns `undefined`. +`experimental_taintObjectReference` מחזירה `undefined`. #### Caveats {/*caveats*/} -- Recreating or cloning a tainted object creates a new untainted object which may contain sensitive data. For example, if you have a tainted `user` object, `const userInfo = {name: user.name, ssn: user.ssn}` or `{...user}` will create new objects which are not tainted. `taintObjectReference` only protects against simple mistakes when the object is passed through to a Client Component unchanged. +- יצירה מחדש או שכפול של אובייקט tainted יוצרת אובייקט חדש שאינו tainted וייתכן שמכיל מידע רגיש. לדוגמה, אם יש לכם אובייקט `user` שמסומן כ-tainted, הקוד `const userInfo = {name: user.name, ssn: user.ssn}` או `{...user}` ייצור אובייקטים חדשים שאינם tainted. ‏`taintObjectReference` מגינה רק מפני טעויות פשוטות שבהן האובייקט מועבר ל-Client Component ללא שינוי. -**Do not rely on just tainting for security.** Tainting an object doesn't prevent leaking of every possible derived value. For example, the clone of a tainted object will create a new untainted object. Using data from a tainted object (e.g. `{secret: taintedObj.secret}`) will create a new value or object that is not tainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns. +**אל תסתמכו רק על tainting לאבטחה.** סימון אובייקט כ-tainted לא מונע דליפה של כל ערך נגזר אפשרי. לדוגמה, שכפול של אובייקט tainted יוצר אובייקט חדש שאינו tainted. שימוש בנתונים מתוך אובייקט tainted (למשל `{secret: taintedObj.secret}`) יוצר ערך או אובייקט חדש שאינו tainted. Tainting היא שכבת הגנה אחת; אפליקציה מאובטחת תכלול כמה שכבות הגנה, APIs מתוכננים היטב ודפוסי בידוד. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Prevent user data from unintentionally reaching the client {/*prevent-user-data-from-unintentionally-reaching-the-client*/} +### מניעת הגעה לא מכוונת של נתוני משתמש ללקוח {/*prevent-user-data-from-unintentionally-reaching-the-client*/} -A Client Component should never accept objects that carry sensitive data. Ideally, the data fetching functions should not expose data that the current user should not have access to. Sometimes mistakes happen during refactoring. To protect against these mistakes happening down the line we can "taint" the user object in our data API. +Client Component לעולם לא אמור לקבל אובייקטים שמכילים מידע רגיש. אידיאלית, פונקציות הבאת הנתונים לא אמורות לחשוף מידע שלמשתמש הנוכחי אין הרשאה אליו. לפעמים קורות טעויות במהלך refactoring. כדי להתגונן מפני טעויות כאלה בהמשך, אפשר "לסמן" את אובייקט המשתמש ב-API הנתונים שלנו. ```js import {experimental_taintObjectReference} from 'react'; @@ -94,13 +94,13 @@ export async function getUser(id) { } ``` -Now whenever anyone tries to pass this object to a Client Component, an error will be thrown with the passed in error message instead. +עכשיו, בכל פעם שמישהו ינסה להעביר את האובייקט הזה ל-Client Component, תיזרק שגיאה עם הודעת השגיאה שהועברה. -#### Protecting against leaks in data fetching {/*protecting-against-leaks-in-data-fetching*/} +#### הגנה מפני דליפות בהבאת נתונים {/*protecting-against-leaks-in-data-fetching*/} -If you're running a Server Components environment that has access to sensitive data, you have to be careful not to pass objects straight through: +אם אתם מריצים סביבת Server Components שיש לה גישה למידע רגיש, צריך להיזהר לא להעביר אובייקטים כמות שהם: ```js // api.js @@ -130,7 +130,7 @@ export async function InfoCard({ user }) { } ``` -Ideally, the `getUser` should not expose data that the current user should not have access to. To prevent passing the `user` object to a Client Component down the line we can "taint" the user object: +אידיאלית, `getUser` לא אמורה לחשוף מידע שלמשתמש הנוכחי אין הרשאה אליו. כדי למנוע העברה של אובייקט `user` ל-Client Component בהמשך הדרך, אפשר "לסמן" אותו כ-tainted: ```js @@ -148,6 +148,6 @@ export async function getUser(id) { } ``` -Now if anyone tries to pass the `user` object to a Client Component, an error will be thrown with the passed in error message. +כעת, אם מישהו ינסה להעביר את אובייקט `user` ל-Client Component, תיזרק שגיאה עם ההודעה שהוגדרה. diff --git a/src/content/reference/react/experimental_taintUniqueValue.md b/src/content/reference/react/experimental_taintUniqueValue.md index 12978758d..5ff0a7187 100644 --- a/src/content/reference/react/experimental_taintUniqueValue.md +++ b/src/content/reference/react/experimental_taintUniqueValue.md @@ -4,30 +4,30 @@ title: experimental_taintUniqueValue -**This API is experimental and is not available in a stable version of React yet.** +**ה-API הזה ניסיוני ועדיין לא זמין בגרסה יציבה של React.** -You can try it by upgrading React packages to the most recent experimental version: +אפשר לנסות אותו על ידי שדרוג חבילות React לגרסה הניסיונית העדכנית ביותר: - `react@experimental` - `react-dom@experimental` - `eslint-plugin-react-hooks@experimental` -Experimental versions of React may contain bugs. Don't use them in production. +גרסאות ניסיוניות של React עשויות להכיל באגים. אל תשתמשו בהן ב-production. -This API is only available inside [React Server Components](/reference/react/use-client). +ה-API הזה זמין רק בתוך [React Server Components](/reference/react/use-client). -`taintUniqueValue` lets you prevent unique values from being passed to Client Components like passwords, keys, or tokens. +`taintUniqueValue` מאפשרת למנוע העברה של ערכים ייחודיים ל-Client Components, כמו סיסמאות, מפתחות או tokens. ```js taintUniqueValue(errMessage, lifetime, value) ``` -To prevent passing an object containing sensitive data, see [`taintObjectReference`](/reference/react/experimental_taintObjectReference). +כדי למנוע העברה של אובייקט שמכיל מידע רגיש, ראו [`taintObjectReference`](/reference/react/experimental_taintObjectReference). @@ -39,7 +39,7 @@ To prevent passing an object containing sensitive data, see [`taintObjectReferen ### `taintUniqueValue(message, lifetime, value)` {/*taintuniquevalue*/} -Call `taintUniqueValue` with a password, token, key or hash to register it with React as something that should not be allowed to be passed to the Client as is: +קראו ל-`taintUniqueValue` עם סיסמה, token, מפתח או hash כדי לרשום אותם ב-React כמשהו שאסור להעביר ללקוח כפי שהוא: ```js import {experimental_taintUniqueValue} from 'react'; @@ -51,34 +51,34 @@ experimental_taintUniqueValue( ); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `message`: The message you want to display if `value` is passed to a Client Component. This message will be displayed as a part of the Error that will be thrown if `value` is passed to a Client Component. +* `message`: ההודעה שתרצו להציג אם `value` מועבר ל-Client Component. הודעה זו תוצג כחלק מה-Error שיושלך אם `value` מועבר ל-Client Component. -* `lifetime`: Any object that indicates how long `value` should be tainted. `value` will be blocked from being sent to any Client Component while this object still exists. For example, passing `globalThis` blocks the value for the lifetime of an app. `lifetime` is typically an object whose properties contains `value`. +* `lifetime`: כל אובייקט שמציין כמה זמן `value` צריך להיות מסומן כ-tainted. `value` ייחסם משליחה לכל Client Component כל עוד האובייקט הזה עדיין קיים. לדוגמה, העברת `globalThis` חוסמת את הערך לאורך כל חיי האפליקציה. לרוב `lifetime` הוא אובייקט שהמאפיינים שלו מכילים את `value`. -* `value`: A string, bigint or TypedArray. `value` must be a unique sequence of characters or bytes with high entropy such as a cryptographic token, private key, hash, or a long password. `value` will be blocked from being sent to any Client Component. +* `value`: מחרוזת, bigint או TypedArray. `value` חייב להיות רצף ייחודי של תווים או בתים עם אנטרופיה גבוהה, כמו token קריפטוגרפי, מפתח פרטי, hash או סיסמה ארוכה. `value` ייחסם משליחה לכל Client Component. #### Returns {/*returns*/} -`experimental_taintUniqueValue` returns `undefined`. +`experimental_taintUniqueValue` מחזירה `undefined`. #### Caveats {/*caveats*/} -* Deriving new values from tainted values can compromise tainting protection. New values created by uppercasing tainted values, concatenating tainted string values into a larger string, converting tainted values to base64, substringing tainted values, and other similar transformations are not tainted unless you explicitly call `taintUniqueValue` on these newly created values. -* Do not use `taintUniqueValue` to protect low-entropy values such as PIN codes or phone numbers. If any value in a request is controlled by an attacker, they could infer which value is tainted by enumerating all possible values of the secret. +* גזירת ערכים חדשים מערכים tainted עלולה לפגוע בהגנת tainting. ערכים חדשים שנוצרים מהמרת אותיות לגדולות, שרשור מחרוזות tainted למחרוזת גדולה יותר, המרה ל-base64, חיתוך תת-מחרוזת מערכים tainted וטרנספורמציות דומות, אינם tainted אלא אם קוראים במפורש ל-`taintUniqueValue` גם על הערכים החדשים. +* אל תשתמשו ב-`taintUniqueValue` להגנה על ערכים בעלי אנטרופיה נמוכה כמו קודי PIN או מספרי טלפון. אם ערך כלשהו בבקשה נשלט על ידי תוקף, הוא עלול להסיק איזה ערך מסומן כ-tainted על ידי מעבר על כל הערכים האפשריים של הסוד. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Prevent a token from being passed to Client Components {/*prevent-a-token-from-being-passed-to-client-components*/} +### מניעת העברת token ל-Client Components {/*prevent-a-token-from-being-passed-to-client-components*/} -To ensure that sensitive information such as passwords, session tokens, or other unique values do not inadvertently get passed to Client Components, the `taintUniqueValue` function provides a layer of protection. When a value is tainted, any attempt to pass it to a Client Component will result in an error. +כדי לוודא שמידע רגיש כמו סיסמאות, session tokens או ערכים ייחודיים אחרים לא מועבר בטעות ל-Client Components, הפונקציה `taintUniqueValue` מספקת שכבת הגנה. כשערך מסומן כ-tainted, כל ניסיון להעביר אותו ל-Client Component יגרום לשגיאה. -The `lifetime` argument defines the duration for which the value remains tainted. For values that should remain tainted indefinitely, objects like [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) or `process` can serve as the `lifetime` argument. These objects have a lifespan that spans the entire duration of your app's execution. +הארגומנט `lifetime` מגדיר את משך הזמן שבו הערך נשאר tainted. לערכים שצריכים להישאר tainted ללא הגבלת זמן, אובייקטים כמו [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) או `process` יכולים לשמש כ-`lifetime`. לאובייקטים האלה יש אורך חיים שחופף לכל משך הרצת האפליקציה. ```js import {experimental_taintUniqueValue} from 'react'; @@ -90,7 +90,7 @@ experimental_taintUniqueValue( ); ``` -If the tainted value's lifespan is tied to a object, the `lifetime` should be the object that encapsulates the value. This ensures the tainted value remains protected for the lifetime of the encapsulating object. +אם אורך החיים של הערך המסומן קשור לאובייקט מסוים, `lifetime` צריך להיות האובייקט שעוטף את הערך. כך מובטח שהערך המסומן יישאר מוגן לאורך חיי האובייקט העוטף. ```js import {experimental_taintUniqueValue} from 'react'; @@ -106,11 +106,11 @@ export async function getUser(id) { } ``` -In this example, the `user` object serves as the `lifetime` argument. If this object gets stored in a global cache or is accessible by another request, the session token remains tainted. +בדוגמה הזו, האובייקט `user` משמש כארגומנט `lifetime`. אם האובייקט הזה נשמר ב-global cache או נגיש מבקשה אחרת, ה-session token נשאר tainted. -**Do not rely solely on tainting for security.** Tainting a value doesn't block every possible derived value. For example, creating a new value by upper casing a tainted string will not taint the new value. +**אל תסתמכו רק על tainting לאבטחה.** סימון ערך כ-tainted לא חוסם כל ערך נגזר אפשרי. לדוגמה, יצירת ערך חדש מהמרת מחרוזת tainted לאותיות גדולות לא תסמן את הערך החדש. ```js @@ -127,19 +127,19 @@ experimental_taintUniqueValue( const uppercasePassword = password.toUpperCase() // `uppercasePassword` is not tainted ``` -In this example, the constant `password` is tainted. Then `password` is used to create a new value `uppercasePassword` by calling the `toUpperCase` method on `password`. The newly created `uppercasePassword` is not tainted. +בדוגמה זו, הקבוע `password` מסומן כ-tainted. לאחר מכן משתמשים ב-`password` ליצירת ערך חדש `uppercasePassword` על ידי קריאה ל-`toUpperCase`. הערך החדש `uppercasePassword` אינו tainted. -Other similar ways of deriving new values from tainted values like concatenating it into a larger string, converting it to base64, or returning a substring create untained values. +שיטות דומות נוספות לגזירת ערכים חדשים מערכים tainted, כמו שרשור למחרוזת גדולה יותר, המרה ל-base64 או החזרת תת-מחרוזת, יוצרות ערכים לא מסומנים. -Tainting only protects against simple mistakes like explicitly passing secret values to the client. Mistakes in calling the `taintUniqueValue` like using a global store outside of React, without the corresponding lifetime object, can cause the tainted value to become untainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns. +Tainting מגינה רק מפני טעויות פשוטות כמו העברה מפורשת של ערכים סודיים ללקוח. טעויות בשימוש ב-`taintUniqueValue`, כמו שימוש ב-global store מחוץ ל-React בלי אובייקט lifetime תואם, עלולות לגרום לכך שהערך המסומן יאבד את הסימון. Tainting היא שכבת הגנה אחת; אפליקציה מאובטחת תכלול כמה שכבות הגנה, APIs מתוכננים היטב ודפוסי בידוד. -#### Using `server-only` and `taintUniqueValue` to prevent leaking secrets {/*using-server-only-and-taintuniquevalue-to-prevent-leaking-secrets*/} +#### שימוש ב-`server-only` ו-`taintUniqueValue` כדי למנוע דליפת סודות {/*using-server-only-and-taintuniquevalue-to-prevent-leaking-secrets*/} -If you're running a Server Components environment that has access to private keys or passwords such as database passwords, you have to be careful not to pass that to a Client Component. +אם אתם מריצים סביבת Server Components שיש לה גישה למפתחות פרטיים או סיסמאות, כמו סיסמת מסד נתונים, צריך להיזהר לא להעביר את זה ל-Client Component. ```js export async function Dashboard(props) { @@ -162,11 +162,11 @@ export async function Overview({ password }) { } ``` -This example would leak the secret API token to the client. If this API token can be used to access data this particular user shouldn't have access to, it could lead to a data breach. +הדוגמה הזו תדליף את סוד ה-API token ללקוח. אם ה-token הזה יכול לשמש לגישה לנתונים שלמשתמש הזה לא אמורה להיות גישה אליהם, זה עלול להוביל לדליפת מידע. [comment]: <> (TODO: Link to `server-only` docs once they are written) -Ideally, secrets like this are abstracted into a single helper file that can only be imported by trusted data utilities on the server. The helper can even be tagged with [`server-only`](https://www.npmjs.com/package/server-only) to ensure that this file isn't imported on the client. +אידיאלית, סודות כאלה יופשטו לקובץ helper יחיד שאפשר לייבא רק מתוך utilities מהימנים בצד השרת. אפשר אפילו לתייג את ה-helper עם [`server-only`](https://www.npmjs.com/package/server-only) כדי להבטיח שהקובץ הזה לא מיובא ללקוח. ```js import "server-only"; @@ -177,8 +177,8 @@ export function fetchAPI(url) { } ``` -Sometimes mistakes happen during refactoring and not all of your colleagues might know about this. -To protect against this mistakes happening down the line we can "taint" the actual password: +לפעמים קורות טעויות במהלך refactoring ולא כל חברי הצוות מודעים לכך. +כדי להתגונן מפני טעויות כאלה בהמשך, אפשר "לסמן" את הסיסמה עצמה: ```js import "server-only"; @@ -192,7 +192,7 @@ experimental_taintUniqueValue( ); ``` -Now whenever anyone tries to pass this password to a Client Component, or send the password to a Client Component with a Server Action, an error will be thrown with message you defined when you called `taintUniqueValue`. +כעת, בכל פעם שמישהו ינסה להעביר את הסיסמה הזו ל-Client Component, או לשלוח אותה ל-Client Component דרך Server Action, תיזרק שגיאה עם ההודעה שהגדרתם בקריאה ל-`taintUniqueValue`. diff --git a/src/content/reference/react/experimental_useEffectEvent.md b/src/content/reference/react/experimental_useEffectEvent.md index e819f041c..896aa63db 100644 --- a/src/content/reference/react/experimental_useEffectEvent.md +++ b/src/content/reference/react/experimental_useEffectEvent.md @@ -4,22 +4,22 @@ title: experimental_useEffectEvent -**This API is experimental and is not available in a stable version of React yet.** +**ה-API הזה ניסיוני ועדיין לא זמין בגרסה יציבה של React.** -You can try it by upgrading React packages to the most recent experimental version: +אפשר לנסות אותו על ידי שדרוג חבילות React לגרסה הניסיונית העדכנית ביותר: - `react@experimental` - `react-dom@experimental` - `eslint-plugin-react-hooks@experimental` -Experimental versions of React may contain bugs. Don't use them in production. +גרסאות ניסיוניות של React עשויות להכיל באגים. אל תשתמשו בהן ב-production. -`useEffectEvent` is a React Hook that lets you extract non-reactive logic into an [Effect Event.](/learn/separating-events-from-effects#declaring-an-effect-event) +`useEffectEvent` הוא React Hook שמאפשר לחלץ לוגיקה לא-ריאקטיבית ל-[Effect Event.](/learn/separating-events-from-effects#declaring-an-effect-event) ```js const onSomething = useEffectEvent(callback) diff --git a/src/content/reference/react/hooks.md b/src/content/reference/react/hooks.md index cec71ce8f..030bcb9a7 100644 --- a/src/content/reference/react/hooks.md +++ b/src/content/reference/react/hooks.md @@ -1,10 +1,10 @@ --- -title: "Built-in React Hooks" +title: "React Hooks מובנים" --- -*Hooks* let you use different React features from your components. You can either use the built-in Hooks or combine them to build your own. This page lists all built-in Hooks in React. +*Hooks* מאפשרים להשתמש ביכולות שונות של React מתוך קומפוננטות. אפשר להשתמש ב-Hooks המובנים, או לשלב ביניהם כדי לבנות Hooks משלכם. העמוד הזה מציג את כל ה-Hooks המובנים ב-React. @@ -12,12 +12,12 @@ title: "Built-in React Hooks" ## State Hooks {/*state-hooks*/} -*State* lets a component ["remember" information like user input.](/learn/state-a-components-memory) For example, a form component can use state to store the input value, while an image gallery component can use state to store the selected image index. +*State* מאפשר לקומפוננטה ["לזכור" מידע כמו קלט מהמשתמש.](/learn/state-a-components-memory) לדוגמה, קומפוננטת טופס יכולה להשתמש ב-state כדי לשמור את ערך הקלט, בעוד קומפוננטת גלריית תמונות יכולה להשתמש ב-state כדי לשמור את אינדקס התמונה שנבחרה. -To add state to a component, use one of these Hooks: +כדי להוסיף state לקומפוננטה, השתמשו באחד מה-Hooks הבאים: -* [`useState`](/reference/react/useState) declares a state variable that you can update directly. -* [`useReducer`](/reference/react/useReducer) declares a state variable with the update logic inside a [reducer function.](/learn/extracting-state-logic-into-a-reducer) +* [`useState`](/reference/react/useState) מצהיר על משתנה state שאפשר לעדכן ישירות. +* [`useReducer`](/reference/react/useReducer) מצהיר על משתנה state עם לוגיקת העדכון בתוך [פונקציית reducer.](/learn/extracting-state-logic-into-a-reducer) ```js function ImageGallery() { @@ -29,9 +29,9 @@ function ImageGallery() { ## Context Hooks {/*context-hooks*/} -*Context* lets a component [receive information from distant parents without passing it as props.](/learn/passing-props-to-a-component) For example, your app's top-level component can pass the current UI theme to all components below, no matter how deep. +*Context* מאפשר לקומפוננטה [לקבל מידע מהורים רחוקים בלי להעביר אותו כ-props.](/learn/passing-props-to-a-component) לדוגמה, קומפוננטת העליונה של האפליקציה יכולה להעביר את ערכת הנושא הנוכחית לכל הקומפוננטות מתחתיה, לא משנה כמה עמוק הן נמצאות. -* [`useContext`](/reference/react/useContext) reads and subscribes to a context. +* [`useContext`](/reference/react/useContext) קורא ל-context ונרשם אליו. ```js function Button() { @@ -43,10 +43,10 @@ function Button() { ## Ref Hooks {/*ref-hooks*/} -*Refs* let a component [hold some information that isn't used for rendering,](/learn/referencing-values-with-refs) like a DOM node or a timeout ID. Unlike with state, updating a ref does not re-render your component. Refs are an "escape hatch" from the React paradigm. They are useful when you need to work with non-React systems, such as the built-in browser APIs. +*Refs* מאפשרים לקומפוננטה [להחזיק מידע שלא משמש לרינדור,](/learn/referencing-values-with-refs) כמו DOM node או מזהה timeout. בניגוד ל-state, עדכון של ref לא מרנדר מחדש את הקומפוננטה. Refs הם "escape hatch" מהפרדיגמה של React. הם שימושיים כשצריך לעבוד עם מערכות שאינן React, כמו APIs מובנים של הדפדפן. -* [`useRef`](/reference/react/useRef) declares a ref. You can hold any value in it, but most often it's used to hold a DOM node. -* [`useImperativeHandle`](/reference/react/useImperativeHandle) lets you customize the ref exposed by your component. This is rarely used. +* [`useRef`](/reference/react/useRef) מצהיר על ref. אפשר לשמור בו כל ערך, אבל לרוב משתמשים בו כדי לשמור DOM node. +* [`useImperativeHandle`](/reference/react/useImperativeHandle) מאפשר להתאים אישית את ה-ref שהקומפוננטה חושפת. זה בשימוש נדיר. ```js function Form() { @@ -58,9 +58,9 @@ function Form() { ## Effect Hooks {/*effect-hooks*/} -*Effects* let a component [connect to and synchronize with external systems.](/learn/synchronizing-with-effects) This includes dealing with network, browser DOM, animations, widgets written using a different UI library, and other non-React code. +*Effects* מאפשרים לקומפוננטה [להתחבר ולהסתנכרן עם מערכות חיצוניות.](/learn/synchronizing-with-effects) זה כולל עבודה עם רשת, DOM של הדפדפן, אנימציות, ווידג'טים שנכתבו בספריית UI אחרת, וקוד נוסף שאינו React. -* [`useEffect`](/reference/react/useEffect) connects a component to an external system. +* [`useEffect`](/reference/react/useEffect) מחבר קומפוננטה למערכת חיצונית. ```js function ChatRoom({ roomId }) { @@ -72,23 +72,23 @@ function ChatRoom({ roomId }) { // ... ``` -Effects are an "escape hatch" from the React paradigm. Don't use Effects to orchestrate the data flow of your application. If you're not interacting with an external system, [you might not need an Effect.](/learn/you-might-not-need-an-effect) +Effects הם "escape hatch" מהפרדיגמה של React. אל תשתמשו ב-Effects כדי לתזמר את זרימת הנתונים של האפליקציה. אם אתם לא מקיימים אינטראקציה עם מערכת חיצונית, [יכול להיות שאין צורך ב-Effect.](/learn/you-might-not-need-an-effect) -There are two rarely used variations of `useEffect` with differences in timing: +יש שתי וריאציות נדירות יותר של `useEffect` עם הבדלים בתזמון: -* [`useLayoutEffect`](/reference/react/useLayoutEffect) fires before the browser repaints the screen. You can measure layout here. -* [`useInsertionEffect`](/reference/react/useInsertionEffect) fires before React makes changes to the DOM. Libraries can insert dynamic CSS here. +* [`useLayoutEffect`](/reference/react/useLayoutEffect) מופעל לפני שהדפדפן מצייר מחדש את המסך. אפשר למדוד layout כאן. +* [`useInsertionEffect`](/reference/react/useInsertionEffect) מופעל לפני ש-React מבצעת שינויים ב-DOM. ספריות יכולות להכניס כאן CSS דינמי. --- ## Performance Hooks {/*performance-hooks*/} -A common way to optimize re-rendering performance is to skip unnecessary work. For example, you can tell React to reuse a cached calculation or to skip a re-render if the data has not changed since the previous render. +דרך נפוצה לאופטימיזציה של ביצועי רינדור מחדש היא לדלג על עבודה מיותרת. לדוגמה, אפשר לבקש מ-React להשתמש מחדש בחישוב שמור או לדלג על רינדור חוזר אם הנתונים לא השתנו מאז הרינדור הקודם. -To skip calculations and unnecessary re-rendering, use one of these Hooks: +כדי לדלג על חישובים ורינדורים מיותרים, השתמשו באחד מה-Hooks הבאים: -- [`useMemo`](/reference/react/useMemo) lets you cache the result of an expensive calculation. -- [`useCallback`](/reference/react/useCallback) lets you cache a function definition before passing it down to an optimized component. +- [`useMemo`](/reference/react/useMemo) מאפשר לשמור במטמון תוצאה של חישוב יקר. +- [`useCallback`](/reference/react/useCallback) מאפשר לשמור במטמון הגדרת פונקציה לפני שמעבירים אותה לקומפוננטה ממוטבת. ```js function TodoList({ todos, tab, theme }) { @@ -97,22 +97,22 @@ function TodoList({ todos, tab, theme }) { } ``` -Sometimes, you can't skip re-rendering because the screen actually needs to update. In that case, you can improve performance by separating blocking updates that must be synchronous (like typing into an input) from non-blocking updates which don't need to block the user interface (like updating a chart). +לפעמים אי אפשר לדלג על רינדור מחדש כי המסך באמת צריך להתעדכן. במקרה כזה אפשר לשפר ביצועים על ידי הפרדה בין עדכונים חוסמים שחייבים להיות סינכרוניים (כמו הקלדה בשדה קלט) לבין עדכונים לא-חוסמים שלא צריכים לחסום את ממשק המשתמש (כמו עדכון גרף). -To prioritize rendering, use one of these Hooks: +כדי לתעדף רינדור, השתמשו באחד מה-Hooks הבאים: -- [`useTransition`](/reference/react/useTransition) lets you mark a state transition as non-blocking and allow other updates to interrupt it. -- [`useDeferredValue`](/reference/react/useDeferredValue) lets you defer updating a non-critical part of the UI and let other parts update first. +- [`useTransition`](/reference/react/useTransition) מאפשר לסמן מעבר state כלא-חוסם ולאפשר לעדכונים אחרים להפריע לו. +- [`useDeferredValue`](/reference/react/useDeferredValue) מאפשר לדחות עדכון של חלק לא-קריטי ב-UI ולאפשר לחלקים אחרים להתעדכן קודם. --- ## Resource Hooks {/*resource-hooks*/} -*Resources* can be accessed by a component without having them as part of their state. For example, a component can read a message from a Promise or read styling information from a context. +*Resources* ניתנים לגישה מתוך קומפוננטה גם בלי להיות חלק מה-state שלה. לדוגמה, קומפוננטה יכולה לקרוא הודעה מתוך Promise או מידע עיצובי מתוך context. -To read a value from a resource, use this Hook: +כדי לקרוא ערך ממשאב, השתמשו ב-Hook הבא: -- [`use`](/reference/react/use) lets you read the value of a resource like a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [context](/learn/passing-data-deeply-with-context). +- [`use`](/reference/react/use) מאפשר לקרוא ערך ממשאב כמו [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) או [context](/learn/passing-data-deeply-with-context). ```js function MessageComponent({ messagePromise }) { @@ -124,16 +124,16 @@ function MessageComponent({ messagePromise }) { --- -## Other Hooks {/*other-hooks*/} +## Hooks נוספים {/*other-hooks*/} -These Hooks are mostly useful to library authors and aren't commonly used in the application code. +ה-Hooks האלה שימושיים בעיקר למחברי ספריות, ולא בשימוש נפוץ בקוד אפליקטיבי. -- [`useDebugValue`](/reference/react/useDebugValue) lets you customize the label React DevTools displays for your custom Hook. -- [`useId`](/reference/react/useId) lets a component associate a unique ID with itself. Typically used with accessibility APIs. -- [`useSyncExternalStore`](/reference/react/useSyncExternalStore) lets a component subscribe to an external store. +- [`useDebugValue`](/reference/react/useDebugValue) מאפשר להתאים את התווית ש-React DevTools מציג עבור custom Hook. +- [`useId`](/reference/react/useId) מאפשר לקומפוננטה לשייך לעצמה מזהה ייחודי. לרוב בשילוב עם APIs של נגישות. +- [`useSyncExternalStore`](/reference/react/useSyncExternalStore) מאפשר לקומפוננטה להירשם לחנות חיצונית. --- -## Your own Hooks {/*your-own-hooks*/} +## Hooks משלכם {/*your-own-hooks*/} -You can also [define your own custom Hooks](/learn/reusing-logic-with-custom-hooks#extracting-your-own-custom-hook-from-a-component) as JavaScript functions. +אפשר גם [להגדיר custom Hooks משלכם](/learn/reusing-logic-with-custom-hooks#extracting-your-own-custom-hook-from-a-component) כפונקציות JavaScript. diff --git a/src/content/reference/react/index.md b/src/content/reference/react/index.md index 6793efc5e..86ef71209 100644 --- a/src/content/reference/react/index.md +++ b/src/content/reference/react/index.md @@ -1,34 +1,34 @@ --- -title: React Reference Overview +title: סקירת Reference של React --- -This section provides detailed reference documentation for working with React. For an introduction to React, please visit the [Learn](/learn) section. +החלק הזה מספק תיעוד reference מפורט לעבודה עם React. להיכרות עם React, עברו לחלק [Learn](/learn). -The React reference documentation is broken down into functional subsections: +תיעוד ה-reference של React מחולק לתתי-חלקים פונקציונליים: ## React {/*react*/} -Programmatic React features: +יכולות React ברמת API: -* [Hooks](/reference/react/hooks) - Use different React features from your components. -* [Components](/reference/react/components) - Documents built-in components that you can use in your JSX. -* [APIs](/reference/react/apis) - APIs that are useful for defining components. -* [Directives](/reference/react/directives) - Provide instructions to bundlers compatible with React Server Components. +* [Hooks](/reference/react/hooks) - שימוש ביכולות שונות של React מתוך הקומפוננטות. +* [Components](/reference/react/components) - תיעוד הקומפוננטות המובנות שאפשר להשתמש בהן ב-JSX. +* [APIs](/reference/react/apis) - APIs שימושיים להגדרת קומפוננטות. +* [Directives](/reference/react/directives) - הנחיות ל-bundlers שתואמים ל-React Server Components. ## React DOM {/*react-dom*/} -React-dom contains features that are only supported for web applications (which run in the browser DOM environment). This section is broken into the following: +`react-dom` כולל יכולות שנתמכות רק באפליקציות ווב (שרצות בסביבת DOM של הדפדפן). החלק הזה מחולק ל: -* [Hooks](/reference/react-dom/hooks) - Hooks for web applications which run in the browser DOM environment. -* [Components](/reference/react-dom/components) - React supports all of the browser built-in HTML and SVG components. -* [APIs](/reference/react-dom) - The `react-dom` package contains methods supported only in web applications. -* [Client APIs](/reference/react-dom/client) - The `react-dom/client` APIs let you render React components on the client (in the browser). -* [Server APIs](/reference/react-dom/server) - The `react-dom/server` APIs let you render React components to HTML on the server. +* [Hooks](/reference/react-dom/hooks) - Hooks לאפליקציות ווב שרצות בסביבת DOM של הדפדפן. +* [Components](/reference/react-dom/components) - React תומכת בכל רכיבי HTML ו-SVG המובנים בדפדפן. +* [APIs](/reference/react-dom) - החבילה `react-dom` כוללת מתודות שנתמכות רק באפליקציות ווב. +* [Client APIs](/reference/react-dom/client) - ה-APIs של `react-dom/client` מאפשרים לרנדר קומפוננטות React בצד לקוח (בדפדפן). +* [Server APIs](/reference/react-dom/server) - ה-APIs של `react-dom/server` מאפשרים לרנדר קומפוננטות React ל-HTML בצד שרת. ## Legacy APIs {/*legacy-apis*/} -* [Legacy APIs](/reference/react/legacy) - Exported from the `react` package, but not recommended for use in newly written code. +* [Legacy APIs](/reference/react/legacy) - מיוצאים מחבילת `react`, אבל לא מומלצים לשימוש בקוד חדש. diff --git a/src/content/reference/react/isValidElement.md b/src/content/reference/react/isValidElement.md index bc4fbaef4..614f538ff 100644 --- a/src/content/reference/react/isValidElement.md +++ b/src/content/reference/react/isValidElement.md @@ -4,7 +4,7 @@ title: isValidElement -`isValidElement` checks whether a value is a React element. +`isValidElement` בודקת האם ערך הוא React element. ```js const isElement = isValidElement(value) @@ -20,7 +20,7 @@ const isElement = isValidElement(value) ### `isValidElement(value)` {/*isvalidelement*/} -Call `isValidElement(value)` to check whether `value` is a React element. +קראו ל-`isValidElement(value)` כדי לבדוק האם `value` הוא React element. ```js import { isValidElement, createElement } from 'react'; @@ -35,34 +35,34 @@ console.log(isValidElement('Hello')); // false console.log(isValidElement({ age: 42 })); // false ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `value`: The `value` you want to check. It can be any a value of any type. +* `value`: הערך שברצונכם לבדוק. הוא יכול להיות מכל סוג. #### Returns {/*returns*/} -`isValidElement` returns `true` if the `value` is a React element. Otherwise, it returns `false`. +`isValidElement` מחזירה `true` אם `value` הוא React element. אחרת היא מחזירה `false`. #### Caveats {/*caveats*/} -* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/reference/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and portals created with [`createPortal`](/reference/react-dom/createPortal) are also *not* considered to be React elements. +* **רק [JSX tags](/learn/writing-markup-with-jsx) ואובייקטים שמוחזרים מ-[`createElement`](/reference/react/createElement) נחשבים ל-React elements.** למשל, למרות שמספר כמו `42` הוא React *node* תקין (ואפשר להחזיר אותו מקומפוננטה), הוא לא React element תקין. גם מערכים ו-portals שנוצרו עם [`createPortal`](/reference/react-dom/createPortal) *לא* נחשבים React elements. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Checking if something is a React element {/*checking-if-something-is-a-react-element*/} +### בדיקה אם משהו הוא React element {/*checking-if-something-is-a-react-element*/} -Call `isValidElement` to check if some value is a *React element.* +קראו ל-`isValidElement` כדי לבדוק אם ערך כלשהו הוא *React element*. -React elements are: +React elements הם: -- Values produced by writing a [JSX tag](/learn/writing-markup-with-jsx) -- Values produced by calling [`createElement`](/reference/react/createElement) +- ערכים שמיוצרים מכתיבת [JSX tag](/learn/writing-markup-with-jsx) +- ערכים שמיוצרים מקריאה ל-[`createElement`](/reference/react/createElement) -For React elements, `isValidElement` returns `true`: +עבור React elements, `isValidElement` מחזירה `true`: ```js import { isValidElement, createElement } from 'react'; @@ -76,9 +76,9 @@ console.log(isValidElement(createElement('p'))); // true console.log(isValidElement(createElement(MyComponent))); // true ``` -Any other values, such as strings, numbers, or arbitrary objects and arrays, are not React elements. +כל ערך אחר, כמו מחרוזות, מספרים או אובייקטים ומערכים שרירותיים, אינו React element. -For them, `isValidElement` returns `false`: +עבורם, `isValidElement` מחזירה `false`: ```js // ❌ These are *not* React elements @@ -90,15 +90,15 @@ console.log(isValidElement([
,
])); // false console.log(isValidElement(MyComponent)); // false ``` -It is very uncommon to need `isValidElement`. It's mostly useful if you're calling another API that *only* accepts elements (like [`cloneElement`](/reference/react/cloneElement) does) and you want to avoid an error when your argument is not a React element. +נדיר מאוד שצריך `isValidElement`. לרוב זה שימושי רק כשקוראים ל-API אחר ש*מקבל רק elements* (כמו [`cloneElement`](/reference/react/cloneElement)) ורוצים להימנע משגיאה כשהארגומנט אינו React element. -Unless you have some very specific reason to add an `isValidElement` check, you probably don't need it. +אלא אם יש לכם סיבה מאוד ספציפית להוסיף בדיקת `isValidElement`, כנראה שאין בה צורך. -#### React elements vs React nodes {/*react-elements-vs-react-nodes*/} +#### React elements לעומת React nodes {/*react-elements-vs-react-nodes*/} -When you write a component, you can return any kind of *React node* from it: +כשכותבים קומפוננטה, אפשר להחזיר ממנה כל סוג של *React node*: ```js function MyComponent() { @@ -106,16 +106,16 @@ function MyComponent() { } ``` -A React node can be: +React node יכול להיות: -- A React element created like `
` or `createElement('div')` -- A portal created with [`createPortal`](/reference/react-dom/createPortal) -- A string -- A number -- `true`, `false`, `null`, or `undefined` (which are not displayed) -- An array of other React nodes +- React element שנוצר כמו `
` או `createElement('div')` +- portal שנוצר עם [`createPortal`](/reference/react-dom/createPortal) +- מחרוזת +- מספר +- `true`, `false`, `null`, או `undefined` (שאינם מוצגים) +- מערך של React nodes אחרים -**Note `isValidElement` checks whether the argument is a *React element,* not whether it's a React node.** For example, `42` is not a valid React element. However, it is a perfectly valid React node: +**שימו לב ש-`isValidElement` בודקת האם הארגומנט הוא *React element*, ולא האם הוא React node.** לדוגמה, `42` אינו React element תקין. עם זאת, הוא React node תקין לחלוטין: ```js function MyComponent() { @@ -123,6 +123,6 @@ function MyComponent() { } ``` -This is why you shouldn't use `isValidElement` as a way to check whether something can be rendered. +לכן לא כדאי להשתמש ב-`isValidElement` כדי לבדוק אם משהו ניתן לרינדור. diff --git a/src/content/reference/react/lazy.md b/src/content/reference/react/lazy.md index db99daa11..70d35d497 100644 --- a/src/content/reference/react/lazy.md +++ b/src/content/reference/react/lazy.md @@ -4,7 +4,7 @@ title: lazy -`lazy` lets you defer loading component's code until it is rendered for the first time. +`lazy` מאפשרת לדחות טעינה של קוד קומפוננטה עד לרינדור הראשון שלה. ```js const SomeComponent = lazy(load) @@ -20,7 +20,7 @@ const SomeComponent = lazy(load) ### `lazy(load)` {/*lazy*/} -Call `lazy` outside your components to declare a lazy-loaded React component: +קראו ל-`lazy` מחוץ לקומפוננטות שלכם כדי להצהיר על קומפוננטת React בטעינה עצלה: ```js import { lazy } from 'react'; @@ -28,41 +28,41 @@ import { lazy } from 'react'; const MarkdownPreview = lazy(() => import('./MarkdownPreview.js')); ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `load`: A function that returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or another *thenable* (a Promise-like object with a `then` method). React will not call `load` until the first time you attempt to render the returned component. After React first calls `load`, it will wait for it to resolve, and then render the resolved value's `.default` as a React component. Both the returned Promise and the Promise's resolved value will be cached, so React will not call `load` more than once. If the Promise rejects, React will `throw` the rejection reason for the nearest Error Boundary to handle. +* `load`: פונקציה שמחזירה [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) או *thenable* אחר (אובייקט דמוי Promise עם מתודת `then`). React לא תקרא ל-`load` עד הפעם הראשונה שבה תנסו לרנדר את הקומפוננטה המוחזרת. אחרי ש-React קוראת ל-`load` בפעם הראשונה, היא תחכה שהפונקציה תיפתר, ואז תרנדר את `.default` של הערך שנפתר כקומפוננטת React. גם ה-Promise המוחזר וגם הערך שנפתר ממנו יישמרו במטמון, כך ש-React לא תקרא ל-`load` יותר מפעם אחת. אם ה-Promise נדחה, React תבצע `throw` לסיבת הדחייה עבור Error Boundary הקרוב כדי שיטפל בה. #### Returns {/*returns*/} -`lazy` returns a React component you can render in your tree. While the code for the lazy component is still loading, attempting to render it will *suspend.* Use [``](/reference/react/Suspense) to display a loading indicator while it's loading. +`lazy` מחזירה קומפוננטת React שאפשר לרנדר בעץ שלכם. בזמן שקוד הקומפוננטה העצלה עדיין נטען, ניסיון לרנדר אותה יגרום ל-*suspend*. השתמשו ב-[``](/reference/react/Suspense) כדי להציג אינדיקציית טעינה בזמן שהיא נטענת. --- -### `load` function {/*load*/} +### פונקציית `load` {/*load*/} #### Parameters {/*load-parameters*/} -`load` receives no parameters. +`load` לא מקבלת פרמטרים. #### Returns {/*load-returns*/} -You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or some other *thenable* (a Promise-like object with a `then` method). It needs to eventually resolve to an object whose `.default` property is a valid React component type, such as a function, [`memo`](/reference/react/memo), or a [`forwardRef`](/reference/react/forwardRef) component. +צריך להחזיר [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) או *thenable* אחר (אובייקט דמוי Promise עם מתודת `then`). בסופו של דבר היא צריכה להיפתר לאובייקט שהמאפיין `.default` שלו הוא סוג קומפוננטת React תקין, כמו פונקציה, קומפוננטת [`memo`](/reference/react/memo), או קומפוננטת [`forwardRef`](/reference/react/forwardRef). --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Lazy-loading components with Suspense {/*suspense-for-code-splitting*/} +### טעינת קומפוננטות בעצלות עם Suspense {/*suspense-for-code-splitting*/} -Usually, you import components with the static [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) declaration: +בדרך כלל מייבאים קומפוננטות באמצעות הצהרת [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) סטטית: ```js import MarkdownPreview from './MarkdownPreview.js'; ``` -To defer loading this component's code until it's rendered for the first time, replace this import with: +כדי לדחות טעינה של קוד הקומפוננטה הזו עד לרינדור הראשון שלה, החליפו את הייבוא הזה ב: ```js import { lazy } from 'react'; @@ -70,9 +70,9 @@ import { lazy } from 'react'; const MarkdownPreview = lazy(() => import('./MarkdownPreview.js')); ``` -This code relies on [dynamic `import()`,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) which might require support from your bundler or framework. Using this pattern requires that the lazy component you're importing was exported as the `default` export. +הקוד הזה נשען על [`import()` דינמי](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import), שעשוי לדרוש תמיכה מה-bundler או מה-framework שלכם. שימוש בדפוס הזה דורש שהקומפוננטה העצלה שאתם מייבאים יוצאה כ-`default` export. -Now that your component's code loads on demand, you also need to specify what should be displayed while it is loading. You can do this by wrapping the lazy component or any of its parents into a [``](/reference/react/Suspense) boundary: +עכשיו, כשהקוד של הקומפוננטה נטען לפי דרישה, צריך גם לציין מה יוצג בזמן הטעינה. אפשר לעשות זאת על ידי עטיפת הקומפוננטה העצלה או אחד מההורים שלה בתוך גבול [``](/reference/react/Suspense): ```js {1,4} }> @@ -81,7 +81,7 @@ Now that your component's code loads on demand, you also need to specify what sh ``` -In this example, the code for `MarkdownPreview` won't be loaded until you attempt to render it. If `MarkdownPreview` hasn't loaded yet, `Loading` will be shown in its place. Try ticking the checkbox: +בדוגמה הזו, הקוד של `MarkdownPreview` לא ייטען עד שתנסו לרנדר אותו. אם `MarkdownPreview` עדיין לא נטען, `Loading` יוצג במקומו. נסו לסמן את תיבת הסימון: @@ -175,17 +175,17 @@ body { -This demo loads with an artificial delay. The next time you untick and tick the checkbox, `Preview` will be cached, so there will be no loading state. To see the loading state again, click "Reset" on the sandbox. +הדמו הזה נטען עם השהיה מלאכותית. בפעם הבאה שתבטלו ותסמנו שוב את תיבת הסימון, `Preview` כבר יהיה במטמון, ולכן לא יהיה מצב טעינה. כדי לראות שוב את מצב הטעינה, לחצו על "Reset" ב-sandbox. -[Learn more about managing loading states with Suspense.](/reference/react/Suspense) +[קראו עוד על ניהול מצבי טעינה עם Suspense.](/reference/react/Suspense) --- -## Troubleshooting {/*troubleshooting*/} +## פתרון תקלות {/*troubleshooting*/} -### My `lazy` component's state gets reset unexpectedly {/*my-lazy-components-state-gets-reset-unexpectedly*/} +### ה-state של קומפוננטת `lazy` מתאפס באופן לא צפוי {/*my-lazy-components-state-gets-reset-unexpectedly*/} -Do not declare `lazy` components *inside* other components: +אל תצהירו על קומפוננטות `lazy` *בתוך* קומפוננטות אחרות: ```js {4-5} import { lazy } from 'react'; @@ -197,7 +197,7 @@ function Editor() { } ``` -Instead, always declare them at the top level of your module: +במקום זאת, תמיד הצהירו עליהן ברמה העליונה של המודול: ```js {3-4} import { lazy } from 'react'; diff --git a/src/content/reference/react/legacy.md b/src/content/reference/react/legacy.md index 407232ada..bcf971d26 100644 --- a/src/content/reference/react/legacy.md +++ b/src/content/reference/react/legacy.md @@ -4,7 +4,7 @@ title: "Legacy React APIs" -These APIs are exported from the `react` package, but they are not recommended for use in newly written code. See the linked individual API pages for the suggested alternatives. +ה-APIs האלה מיוצאים מחבילת `react`, אבל לא מומלצים לשימוש בקוד חדש. ראו את עמודי ה-API המקושרים עבור חלופות מומלצות. @@ -12,23 +12,23 @@ These APIs are exported from the `react` package, but they are not recommended f ## Legacy APIs {/*legacy-apis*/} -* [`Children`](/reference/react/Children) lets you manipulate and transform the JSX received as the `children` prop. [See alternatives.](/reference/react/Children#alternatives) -* [`cloneElement`](/reference/react/cloneElement) lets you create a React element using another element as a starting point. [See alternatives.](/reference/react/cloneElement#alternatives) -* [`Component`](/reference/react/Component) lets you define a React component as a JavaScript class. [See alternatives.](/reference/react/Component#alternatives) -* [`createElement`](/reference/react/createElement) lets you create a React element. Typically, you'll use JSX instead. -* [`createRef`](/reference/react/createRef) creates a ref object which can contain arbitrary value. [See alternatives.](/reference/react/createRef#alternatives) -* [`isValidElement`](/reference/react/isValidElement) checks whether a value is a React element. Typically used with [`cloneElement`.](/reference/react/cloneElement) -* [`PureComponent`](/reference/react/PureComponent) is similar to [`Component`,](/reference/react/Component) but it skip re-renders with same props. [See alternatives.](/reference/react/PureComponent#alternatives) +* [`Children`](/reference/react/Children) מאפשר לבצע מניפולציה וטרנספורמציה ל-JSX שהתקבל דרך prop בשם `children`. [ראו חלופות.](/reference/react/Children#alternatives) +* [`cloneElement`](/reference/react/cloneElement) מאפשר ליצור React element מנקודת התחלה של element אחר. [ראו חלופות.](/reference/react/cloneElement#alternatives) +* [`Component`](/reference/react/Component) מאפשר להגדיר קומפוננטת React כ-class ב-JavaScript. [ראו חלופות.](/reference/react/Component#alternatives) +* [`createElement`](/reference/react/createElement) מאפשר ליצור React element. בדרך כלל תשתמשו ב-JSX במקום. +* [`createRef`](/reference/react/createRef) יוצר אובייקט ref שיכול להכיל כל ערך. [ראו חלופות.](/reference/react/createRef#alternatives) +* [`isValidElement`](/reference/react/isValidElement) בודק האם ערך הוא React element. בדרך כלל בשימוש עם [`cloneElement`.](/reference/react/cloneElement) +* [`PureComponent`](/reference/react/PureComponent) דומה ל-[`Component`,](/reference/react/Component) אבל מדלג על רינדורים חוזרים עם אותם props. [ראו חלופות.](/reference/react/PureComponent#alternatives) --- -## Deprecated APIs {/*deprecated-apis*/} +## APIs שהוצאו משימוש {/*deprecated-apis*/} -These APIs will be removed in a future major version of React. +ה-APIs האלה יוסרו בגרסה ראשית עתידית של React. -* [`createFactory`](/reference/react/createFactory) lets you create a function that produces React elements of a certain type. +* [`createFactory`](/reference/react/createFactory) מאפשר ליצור פונקציה שמייצרת React elements מסוג מסוים. diff --git a/src/content/reference/react/startTransition.md b/src/content/reference/react/startTransition.md index 0aef23fd3..f54089651 100644 --- a/src/content/reference/react/startTransition.md +++ b/src/content/reference/react/startTransition.md @@ -4,7 +4,7 @@ title: startTransition -`startTransition` lets you update the state without blocking the UI. +`startTransition` מאפשר לעדכן state בלי לחסום את ה-UI. ```js startTransition(scope) @@ -20,7 +20,7 @@ startTransition(scope) ### `startTransition(scope)` {/*starttransitionscope*/} -The `startTransition` function lets you mark a state update as a transition. +הפונקציה `startTransition` מאפשרת לסמן עדכון state כ-transition. ```js {7,9} import { startTransition } from 'react'; @@ -37,37 +37,37 @@ function TabContainer() { } ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `scope`: A function that updates some state by calling one or more [`set` functions.](/reference/react/useState#setstate) React immediately calls `scope` with no arguments and marks all state updates scheduled synchronously during the `scope` function call as transitions. They will be [non-blocking](/reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition) and [will not display unwanted loading indicators.](/reference/react/useTransition#preventing-unwanted-loading-indicators) +* `scope`: פונקציה שמעדכנת state על ידי קריאה לפונקציית `set` אחת או יותר.[`set` functions.](/reference/react/useState#setstate) React קוראת ל-`scope` מיד ללא ארגומנטים, ומסמנת כל עדכון state שמתוזמן באופן סינכרוני במהלך הקריאה ל-`scope` כ-transition. העדכונים יהיו [לא-חוסמים](/reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition) ו-[לא יציגו מחווני טעינה לא רצויים.](/reference/react/useTransition#preventing-unwanted-loading-indicators) #### Returns {/*returns*/} -`startTransition` does not return anything. +`startTransition` לא מחזירה דבר. #### Caveats {/*caveats*/} -* `startTransition` does not provide a way to track whether a transition is pending. To show a pending indicator while the transition is ongoing, you need [`useTransition`](/reference/react/useTransition) instead. +* `startTransition` לא מספקת דרך לעקוב אם transition ממתין. כדי להציג אינדיקציית pending בזמן שה-transition מתבצע, צריך להשתמש ב-[`useTransition`](/reference/react/useTransition). -* You can wrap an update into a transition only if you have access to the `set` function of that state. If you want to start a transition in response to some prop or a custom Hook return value, try [`useDeferredValue`](/reference/react/useDeferredValue) instead. +* אפשר לעטוף עדכון בתוך transition רק אם יש לכם גישה לפונקציית ה-`set` של אותו state. אם רוצים להתחיל transition בתגובה ל-prop או לערך שמוחזר מ-custom Hook, נסו להשתמש ב-[`useDeferredValue`](/reference/react/useDeferredValue). -* The function you pass to `startTransition` must be synchronous. React immediately executes this function, marking all state updates that happen while it executes as transitions. If you try to perform more state updates later (for example, in a timeout), they won't be marked as transitions. +* הפונקציה שמעבירים ל-`startTransition` חייבת להיות סינכרונית. React מבצעת אותה מיד ומסמנת כ-transition את כל עדכוני ה-state שמתרחשים בזמן הביצוע. אם תנסו לבצע עדכוני state נוספים מאוחר יותר (למשל ב-timeout), הם לא יסומנו כ-transition. -* A state update marked as a transition will be interrupted by other state updates. For example, if you update a chart component inside a transition, but then start typing into an input while the chart is in the middle of a re-render, React will restart the rendering work on the chart component after handling the input state update. +* עדכון state שסומן כ-transition יופרע על ידי עדכוני state אחרים. לדוגמה, אם מעדכנים קומפוננטת גרף בתוך transition ואז מתחילים להקליד בשדה קלט בזמן שהגרף באמצע רינדור מחדש, React תתחיל מחדש את עבודת הרינדור על הגרף אחרי טיפול בעדכון ה-state של הקלט. -* Transition updates can't be used to control text inputs. +* אי אפשר להשתמש בעדכוני transition כדי לשלוט בשדות קלט טקסט. -* If there are multiple ongoing transitions, React currently batches them together. This is a limitation that will likely be removed in a future release. +* אם יש כמה transitions בו-זמנית, React כרגע מאגדת אותם יחד. זו מגבלה שככל הנראה תוסר בגרסה עתידית. --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Marking a state update as a non-blocking transition {/*marking-a-state-update-as-a-non-blocking-transition*/} +### סימון עדכון state כ-transition לא חוסם {/*marking-a-state-update-as-a-non-blocking-transition*/} -You can mark a state update as a *transition* by wrapping it in a `startTransition` call: +אפשר לסמן עדכון state כ-*transition* על ידי עטיפה שלו בקריאה ל-`startTransition`: ```js {7,9} import { startTransition } from 'react'; @@ -84,14 +84,14 @@ function TabContainer() { } ``` -Transitions let you keep the user interface updates responsive even on slow devices. +Transitions מאפשרים לשמור על תגובתיות עדכוני ממשק המשתמש גם במכשירים איטיים. -With a transition, your UI stays responsive in the middle of a re-render. For example, if the user clicks a tab but then change their mind and click another tab, they can do that without waiting for the first re-render to finish. +עם transition, ה-UI נשאר תגובתי גם בזמן רינדור מחדש. למשל, אם משתמש לוחץ על טאב ואז משנה את דעתו ולוחץ על טאב אחר, הוא יכול לעשות זאת בלי להמתין שהרינדור מחדש הראשון יסתיים. -`startTransition` is very similar to [`useTransition`](/reference/react/useTransition), except that it does not provide the `isPending` flag to track whether a transition is ongoing. You can call `startTransition` when `useTransition` is not available. For example, `startTransition` works outside components, such as from a data library. +`startTransition` מאוד דומה ל-[`useTransition`](/reference/react/useTransition), חוץ מזה שהיא לא מספקת את הדגל `isPending` למעקב אחרי transition שמתבצע. אפשר לקרוא ל-`startTransition` כש-`useTransition` לא זמין. לדוגמה, `startTransition` עובדת מחוץ לקומפוננטות, כמו מתוך ספריית נתונים. -[Learn about transitions and see examples on the `useTransition` page.](/reference/react/useTransition) +[למדו על transitions וראו דוגמאות בעמוד של `useTransition`.](/reference/react/useTransition) diff --git a/src/content/reference/react/use-server.md b/src/content/reference/react/use-server.md index d517873b7..53729147c 100644 --- a/src/content/reference/react/use-server.md +++ b/src/content/reference/react/use-server.md @@ -6,14 +6,14 @@ canary: true -`'use server'` is needed only if you're [using React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) or building a library compatible with them. +`'use server'` נדרש רק אם אתם [משתמשים ב-React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) או בונים ספרייה שתואמת אליהם. -`'use server'` marks server-side functions that can be called from client-side code. +`'use server'` מסמן פונקציות בצד השרת שאפשר לקרוא להן מקוד בצד הלקוח. @@ -21,11 +21,11 @@ canary: true --- -## Reference {/*reference*/} +## עיון ב-API {/*reference*/} ### `'use server'` {/*use-server*/} -Add `'use server'` at the top of an async function body to mark the function as callable by the client. We call these functions _Server Actions_. +הוסיפו `'use server'` בתחילת גוף של פונקציה אסינכרונית כדי לסמן אותה כפונקציה שהלקוח יכול לקרוא לה. לפונקציות האלו אנחנו קוראים _Server Actions_. ```js {2} async function addToCart(data) { @@ -34,77 +34,77 @@ async function addToCart(data) { } ``` -When calling a Server Action on the client, it will make a network request to the server that includes a serialized copy of any arguments passed. If the Server Action returns a value, that value will be serialized and returned to the client. +כשקוראים ל-Server Action מהלקוח, מתבצעת בקשת רשת לשרת שכוללת עותק מסודר (serialized) של כל הארגומנטים שהועברו. אם ה-Server Action מחזיר ערך, הערך הזה יעבור serialization ויוחזר ללקוח. -Instead of individually marking functions with `'use server'`, you can add the directive to the top of a file to mark all exports within that file as Server Actions that can be used anywhere, including imported in client code. +במקום לסמן כל פונקציה בנפרד עם `'use server'`, אפשר להוסיף את ההנחיה בראש קובץ כדי לסמן שכל ה-exports בקובץ הם Server Actions שאפשר להשתמש בהם מכל מקום, כולל ייבוא מתוך קוד לקוח. -#### Caveats {/*caveats*/} -* `'use server'` must be at the very beginning of their function or module; above any other code including imports (comments above directives are OK). They must be written with single or double quotes, not backticks. -* `'use server'` can only be used in server-side files. The resulting Server Actions can be passed to Client Components through props. See supported [types for serialization](#serializable-parameters-and-return-values). -* To import a Server Action from [client code](/reference/react/use-client), the directive must be used on a module level. -* Because the underlying network calls are always asynchronous, `'use server'` can only be used on async functions. -* Always treat arguments to Server Actions as untrusted input and authorize any mutations. See [security considerations](#security). -* Server Actions should be called in a [transition](/reference/react/useTransition). Server Actions passed to [``](/reference/react-dom/components/form#props) or [`formAction`](/reference/react-dom/components/input#props) will automatically be called in a transition. -* Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value. +#### הבהרות {/*caveats*/} +* `'use server'` חייב להופיע ממש בתחילת הפונקציה או המודול, לפני כל קוד אחר כולל imports (מותרות הערות מעל ההנחיה). יש לכתוב אותו במרכאות יחידות או כפולות, לא עם backticks. +* אפשר להשתמש ב-`'use server'` רק בקבצים שרצים בצד השרת. את ה-Server Actions שנוצרים אפשר להעביר ל-Client Components דרך props. ראו [types נתמכים ל-serialization](#serializable-parameters-and-return-values). +* כדי לייבא Server Action מתוך [קוד לקוח](/reference/react/use-client), ההנחיה חייבת להיות ברמת מודול. +* מכיוון שקריאות הרשת מתחת למכסה המנוע הן תמיד אסינכרוניות, אפשר להשתמש ב-`'use server'` רק על פונקציות async. +* התייחסו תמיד לארגומנטים של Server Actions כקלט לא מהימן ובצעו הרשאה לכל שינוי מצב. ראו [שיקולי אבטחה](#security). +* מומלץ לקרוא ל-Server Actions בתוך [transition](/reference/react/useTransition). Server Actions שמועברים ל-[``](/reference/react-dom/components/form#props) או ל-[`formAction`](/reference/react-dom/components/input#props) ירוצו אוטומטית בתוך transition. +* Server Actions מיועדים למוטציות שמעדכנות מצב בצד השרת; הם לא מומלצים לשליפת נתונים. בהתאם לכך, frameworks שמממשים Server Actions לרוב מעבדים פעולה אחת בכל פעם ואין להם דרך למטמן את ערך החזרה. -### Security considerations {/*security*/} +### שיקולי אבטחה {/*security*/} -Arguments to Server Actions are fully client-controlled. For security, always treat them as untrusted input, and make sure to validate and escape arguments as appropriate. +הארגומנטים ל-Server Actions נשלטים לגמרי על ידי הלקוח. מטעמי אבטחה, התייחסו אליהם תמיד כקלט לא מהימן, ודאו שאתם מאמתים ומבצעים escaping לארגומנטים לפי הצורך. -In any Server Action, make sure to validate that the logged-in user is allowed to perform that action. +בכל Server Action, ודאו שהמשתמש המחובר מורשה לבצע את הפעולה. -To prevent sending sensitive data from a Server Action, there are experimental taint APIs to prevent unique values and objects from being passed to client code. +כדי למנוע שליחה של מידע רגיש מתוך Server Action, קיימים APIs ניסיוניים מסוג taint שמונעים העברת ערכים ייחודיים ואובייקטים לקוד לקוח. -See [experimental_taintUniqueValue](/reference/react/experimental_taintUniqueValue) and [experimental_taintObjectReference](/reference/react/experimental_taintObjectReference). +ראו [experimental_taintUniqueValue](/reference/react/experimental_taintUniqueValue) ו-[experimental_taintObjectReference](/reference/react/experimental_taintObjectReference). -### Serializable arguments and return values {/*serializable-parameters-and-return-values*/} +### ארגומנטים וערכי החזרה שניתנים ל-serialization {/*serializable-parameters-and-return-values*/} -As client code calls the Server Action over the network, any arguments passed will need to be serializable. +מכיוון שקוד לקוח קורא ל-Server Action דרך הרשת, כל הארגומנטים שמועברים חייבים להיות ניתנים ל-serialization. -Here are supported types for Server Action arguments: +אלה הסוגים הנתמכים לארגומנטים של Server Action: -* Primitives +* פרימיטיביים * [string](https://developer.mozilla.org/en-US/docs/Glossary/String) * [number](https://developer.mozilla.org/en-US/docs/Glossary/Number) * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) * [boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean) * [undefined](https://developer.mozilla.org/en-US/docs/Glossary/Undefined) * [null](https://developer.mozilla.org/en-US/docs/Glossary/Null) - * [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), only symbols registered in the global Symbol registry via [`Symbol.for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for) -* Iterables containing serializable values + * [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), רק symbols שנרשמו ב-global Symbol registry דרך [`Symbol.for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for) +* איטרטורים שמכילים ערכים שניתנים ל-serialization * [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) * [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) * [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) * [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) - * [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) and [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) + * [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) ו-[ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) * [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) -* [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) instances -* Plain [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object): those created with [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer), with serializable properties -* Functions that are Server Actions +* מופעי [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) +* [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) פשוטים: כאלה שנוצרו עם [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer), עם מאפיינים שניתנים ל-serialization +* פונקציות שהן Server Actions * [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) -Notably, these are not supported: -* React elements, or [JSX](/learn/writing-markup-with-jsx) -* Functions, including component functions or any other function that is not a Server Action +לעומת זאת, אלה אינם נתמכים: +* React elements או [JSX](/learn/writing-markup-with-jsx) +* פונקציות, כולל פונקציות קומפוננטה או כל פונקציה אחרת שאינה Server Action * [Classes](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Classes_in_JavaScript) -* Objects that are instances of any class (other than the built-ins mentioned) or objects with [a null prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects) -* Symbols not registered globally, ex. `Symbol('my new symbol')` +* אובייקטים שהם מופעים של כל class (מלבד ה-built-ins שהוזכרו) או אובייקטים עם [null prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects) +* Symbols שלא נרשמו גלובלית, לדוגמה: `Symbol('my new symbol')` -Supported serializable return values are the same as [serializable props](/reference/react/use-client#passing-props-from-server-to-client-components) for a boundary Client Component. +ערכי חזרה נתמכים ב-serialization זהים ל-[serializable props](/reference/react/use-client#passing-props-from-server-to-client-components) עבור Client Component בגבול. -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Server Actions in forms {/*server-actions-in-forms*/} +### Server Actions בתוך טפסים {/*server-actions-in-forms*/} -The most common use case of Server Actions will be calling server functions that mutate data. On the browser, the [HTML form element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) is the traditional approach for a user to submit a mutation. With React Server Components, React introduces first-class support for Server Actions in [forms](/reference/react-dom/components/form). +מקרה השימוש הנפוץ ביותר ל-Server Actions הוא קריאה לפונקציות שרת שמבצעות מוטציה בנתונים. בדפדפן, אלמנט [HTML form](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) הוא הדרך המסורתית לשלוח מוטציה מצד המשתמש. עם React Server Components, React מוסיף תמיכה מדרגה ראשונה ב-Server Actions בתוך [forms](/reference/react-dom/components/form). -Here is a form that allows a user to request a username. +הנה טופס שמאפשר למשתמש לבקש שם משתמש. ```js [[1, 3, "formData"]] // App.js @@ -125,15 +125,15 @@ export default function App() { } ``` -In this example `requestUsername` is a Server Action passed to a ``. When a user submits this form, there is a network request to the server function `requestUsername`. When calling a Server Action in a form, React will supply the form's [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) as the first argument to the Server Action. +בדוגמה הזו `requestUsername` הוא Server Action שמועבר ל-``. כשמשתמש שולח את הטופס, מתבצעת בקשת רשת לפונקציית השרת `requestUsername`. כשקוראים ל-Server Action מתוך טופס, React יעביר את [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) של הטופס כארגומנט ראשון ל-Server Action. -By passing a Server Action to the form `action`, React can [progressively enhance](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement) the form. This means that forms can be submitted before the JavaScript bundle is loaded. +על ידי העברת Server Action ל-`action` של הטופס, React יכול [לבצע progressive enhancement](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement) לטופס. המשמעות היא שאפשר לשלוח טפסים גם לפני שחבילת JavaScript נטענה. -#### Handling return values in forms {/*handling-return-values*/} +#### טיפול בערכי חזרה בטפסים {/*handling-return-values*/} -In the username request form, there might be the chance that a username is not available. `requestUsername` should tell us if it fails or not. +בטופס בקשת שם משתמש ייתכן שהשם לא זמין. `requestUsername` צריך להחזיר לנו אם הפעולה הצליחה או נכשלה. -To update the UI based on the result of a Server Action while supporting progressive enhancement, use [`useFormState`](/reference/react-dom/hooks/useFormState). +כדי לעדכן את ה-UI לפי תוצאת Server Action תוך תמיכה ב-progressive enhancement, השתמשו ב-[`useFormState`](/reference/react-dom/hooks/useFormState). ```js // requestUsername.js @@ -171,13 +171,13 @@ function UsernameForm() { } ``` -Note that like most Hooks, `useFormState` can only be called in [client code](/reference/react/use-client). +שימו לב שכמו רוב ה-Hooks, `useFormState` יכול להיקרא רק מתוך [קוד לקוח](/reference/react/use-client). -### Calling a Server Action outside of `` {/*calling-a-server-action-outside-of-form*/} +### קריאה ל-Server Action מחוץ ל-`` {/*calling-a-server-action-outside-of-form*/} -Server Actions are exposed server endpoints and can be called anywhere in client code. +Server Actions הם endpoints בשרת, ואפשר לקרוא להם מכל מקום בקוד לקוח. -When using a Server Action outside of a [form](/reference/react-dom/components/form), call the Server Action in a [transition](/reference/react/useTransition), which allows you to display a loading indicator, show [optimistic state updates](/reference/react/useOptimistic), and handle unexpected errors. Forms will automatically wrap Server Actions in transitions. +כשמשתמשים ב-Server Action מחוץ ל-[form](/reference/react-dom/components/form), קראו לו בתוך [transition](/reference/react/useTransition), כדי שתוכלו להציג אינדיקציית טעינה, להראות [optimistic state updates](/reference/react/useOptimistic), ולטפל בשגיאות לא צפויות. טפסים עוטפים Server Actions אוטומטית בתוך transitions. ```js {9-12} import incrementLike from './actions'; @@ -214,4 +214,4 @@ export default async function incrementLike() { } ``` -To read a Server Action return value, you'll need to `await` the promise returned. +כדי לקרוא את ערך החזרה של Server Action צריך לבצע `await` ל-promise שמוחזר. diff --git a/src/content/reference/react/useDebugValue.md b/src/content/reference/react/useDebugValue.md index 62db9e6b2..a4ee088c0 100644 --- a/src/content/reference/react/useDebugValue.md +++ b/src/content/reference/react/useDebugValue.md @@ -4,7 +4,7 @@ title: useDebugValue -`useDebugValue` is a React Hook that lets you add a label to a custom Hook in [React DevTools.](/learn/react-developer-tools) +`useDebugValue` הוא React Hook שמאפשר להוסיף תווית ל-custom Hook בתוך [React DevTools.](/learn/react-developer-tools) ```js useDebugValue(value, format?) @@ -20,7 +20,7 @@ useDebugValue(value, format?) ### `useDebugValue(value, format?)` {/*usedebugvalue*/} -Call `useDebugValue` at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value: +קראו ל-`useDebugValue` ברמה העליונה של [custom Hook](/learn/reusing-logic-with-custom-hooks) כדי להציג ערך דיבוג קריא: ```js import { useDebugValue } from 'react'; @@ -32,22 +32,22 @@ function useOnlineStatus() { } ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -* `value`: The value you want to display in React DevTools. It can have any type. -* **optional** `format`: A formatting function. When the component is inspected, React DevTools will call the formatting function with the `value` as the argument, and then display the returned formatted value (which may have any type). If you don't specify the formatting function, the original `value` itself will be displayed. +* `value`: הערך שאתם רוצים להציג ב-React DevTools. יכול להיות מכל סוג. +* **אופציונלי** `format`: פונקציית עיצוב. כשבודקים את הקומפוננטה, React DevTools תקרא לפונקציית העיצוב עם `value` כארגומנט, ואז תציג את הערך המעוצב שהוחזר (שגם הוא יכול להיות מכל סוג). אם לא מציינים פונקציית עיצוב, יוצג הערך המקורי `value`. #### Returns {/*returns*/} -`useDebugValue` does not return anything. +`useDebugValue` לא מחזירה דבר. -## Usage {/*usage*/} +## שימוש {/*usage*/} -### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/} +### הוספת תווית ל-custom Hook {/*adding-a-label-to-a-custom-hook*/} -Call `useDebugValue` at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value for [React DevTools.](/learn/react-developer-tools) +קראו ל-`useDebugValue` ברמה העליונה של [custom Hook](/learn/reusing-logic-with-custom-hooks) כדי להציג ערך דיבוג קריא עבור [React DevTools.](/learn/react-developer-tools) ```js [[1, 5, "isOnline ? 'Online' : 'Offline'"]] import { useDebugValue } from 'react'; @@ -59,11 +59,11 @@ function useOnlineStatus() { } ``` -This gives components calling `useOnlineStatus` a label like `OnlineStatus: "Online"` when you inspect them: +כך קומפוננטות שקוראות ל-`useOnlineStatus` יקבלו תווית כמו `OnlineStatus: "Online"` כשבודקים אותן: ![A screenshot of React DevTools showing the debug value](/images/docs/react-devtools-usedebugvalue.png) -Without the `useDebugValue` call, only the underlying data (in this example, `true`) would be displayed. +בלי הקריאה ל-`useDebugValue`, יוצגו רק הנתונים הבסיסיים (בדוגמה הזאת, `true`). @@ -103,20 +103,20 @@ function subscribe(callback) { -Don't add debug values to every custom Hook. It's most valuable for custom Hooks that are part of shared libraries and that have a complex internal data structure that's difficult to inspect. +אל תוסיפו ערכי דיבוג לכל custom Hook. זה הכי שימושי עבור custom Hooks שהם חלק מספריות משותפות ושיש להם מבנה נתונים פנימי מורכב שקשה לבדוק. --- -### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/} +### דחיית עיצוב של ערך דיבוג {/*deferring-formatting-of-a-debug-value*/} -You can also pass a formatting function as the second argument to `useDebugValue`: +אפשר גם להעביר פונקציית עיצוב כארגומנט שני ל-`useDebugValue`: ```js [[1, 1, "date", 18], [2, 1, "date.toDateString()"]] useDebugValue(date, date => date.toDateString()); ``` -Your formatting function will receive the debug value as a parameter and should return a formatted display value. When your component is inspected, React DevTools will call this function and display its result. +פונקציית העיצוב תקבל את ערך הדיבוג כפרמטר וצריכה להחזיר ערך תצוגה מעוצב. כשבודקים את הקומפוננטה, React DevTools תקרא לפונקציה הזו ותציג את התוצאה. -This lets you avoid running potentially expensive formatting logic unless the component is actually inspected. For example, if `date` is a Date value, this avoids calling `toDateString()` on it for every render. +כך אפשר להימנע מהרצת לוגיקת עיצוב יקרה אלא אם הקומפוננטה באמת נבדקת. לדוגמה, אם `date` הוא ערך מסוג Date, זה מונע קריאה ל-`toDateString()` בכל רינדור. diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md index c97120eba..9dfd52fba 100644 --- a/src/content/reference/react/useId.md +++ b/src/content/reference/react/useId.md @@ -4,7 +4,7 @@ title: useId -`useId` is a React Hook for generating unique IDs that can be passed to accessibility attributes. +`useId` הוא React Hook ליצירת מזהים ייחודיים שאפשר להעביר למאפייני נגישות. ```js const id = useId() @@ -20,7 +20,7 @@ const id = useId() ### `useId()` {/*useid*/} -Call `useId` at the top level of your component to generate a unique ID: +קראו ל-`useId` ברמה העליונה של הקומפוננטה כדי ליצור מזהה ייחודי: ```js import { useId } from 'react'; @@ -30,35 +30,35 @@ function PasswordField() { // ... ``` -[See more examples below.](#usage) +[ראו דוגמאות נוספות בהמשך.](#usage) #### Parameters {/*parameters*/} -`useId` does not take any parameters. +`useId` לא מקבל פרמטרים. #### Returns {/*returns*/} -`useId` returns a unique ID string associated with this particular `useId` call in this particular component. +`useId` מחזיר מחרוזת מזהה ייחודית שמשויכת לקריאה הספציפית הזו ל-`useId` בתוך הקומפוננטה הספציפית הזו. #### Caveats {/*caveats*/} -* `useId` is a Hook, so you can only call it **at the top level of your component** or your own Hooks. You can't call it inside loops or conditions. If you need that, extract a new component and move the state into it. +* `useId` הוא Hook, לכן אפשר לקרוא לו **רק ברמה העליונה של הקומפוננטה** או של Hooks משלכם. אי אפשר לקרוא לו בתוך לולאות או תנאים. אם צריך את זה, חלצו קומפוננטה חדשה והעבירו אליה את ה-state. -* `useId` **should not be used to generate keys** in a list. [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key) +* **לא צריך להשתמש ב-`useId` כדי לייצר keys** ברשימה. [Keys צריכים להיווצר מהנתונים שלכם.](/learn/rendering-lists#where-to-get-your-key) --- -## Usage {/*usage*/} +## שימוש {/*usage*/} -**Do not call `useId` to generate keys in a list.** [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key) +**אל תקראו ל-`useId` כדי לייצר keys ברשימה.** [Keys צריכים להיווצר מהנתונים שלכם.](/learn/rendering-lists#where-to-get-your-key) -### Generating unique IDs for accessibility attributes {/*generating-unique-ids-for-accessibility-attributes*/} +### יצירת מזהים ייחודיים למאפייני נגישות {/*generating-unique-ids-for-accessibility-attributes*/} -Call `useId` at the top level of your component to generate a unique ID: +קראו ל-`useId` ברמה העליונה של הקומפוננטה כדי ליצור מזהה ייחודי: ```js [[1, 4, "passwordHintId"]] import { useId } from 'react'; @@ -68,7 +68,7 @@ function PasswordField() { // ... ``` -You can then pass the generated ID to different attributes: +לאחר מכן אפשר להעביר את המזהה שנוצר למאפיינים שונים: ```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]] <> @@ -77,11 +77,11 @@ You can then pass the generated ID to different at ``` -**Let's walk through an example to see when this is useful.** +**בואו נעבור על דוגמה כדי לראות מתי זה שימושי.** -[HTML accessibility attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) like [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) let you specify that two tags are related to each other. For example, you can specify that an element (like an input) is described by another element (like a paragraph). +[מאפייני נגישות ב-HTML](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) כמו [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) מאפשרים לציין ששתי תגיות קשורות זו לזו. למשל, אפשר לציין שאלמנט אחד (כמו input) מתואר על ידי אלמנט אחר (כמו פסקה). -In regular HTML, you would write it like this: +ב-HTML רגיל, הייתם כותבים כך: ```html {5,8}