You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/error-boundaries.md
+14-13Lines changed: 14 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,9 +103,9 @@ class ErrorBoundary extends React.Component {
103
103
> שמות הקומפוננטות שמוצגים במעקב הערימות תלוי בשם שהוגדר במאפיין [`Function.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name). אם אתם צריכים לתמוך בדפדפנים או מכשירים ישנים יותר שלא תומכים בזה באופן סטנדרטי (כמו IE 11 למשל), תוכלו להוסיף את המאפיין כ- polyfill שיוכלל ב-bundle האפליקציה, כמו [`function.name-polyfill`](https://github.com/JamesMGreene/Function.name). דרך נוספת היא לספק באופן ישיר את המאפיין [`displayName`](/docs/react-component.html#displayname) בכל קומפוננטה.
104
104
105
105
106
-
## How About try/catch? {#how-about-trycatch}
106
+
## מה עם בלוק try/catch? {#how-about-trycatch}
107
107
108
-
`try` / `catch`is great but it only works for imperative code:
108
+
בלוק `try/catch`זה מצוין אבל עובד רק בקוד אימפרטיבי (קוד שמשנה את מצב האפליקציה):
109
109
110
110
```js
111
111
try {
@@ -115,21 +115,22 @@ try {
115
115
}
116
116
```
117
117
118
-
However, React components are declarative and specify *what* should be rendered:
118
+
לעומת זאת, קומפוננטות React הן דקלרטיביות ורק מציינות *מה* צריך לרנדר באפליקציה:
119
119
120
120
```js
121
121
<Button />
122
122
```
123
123
124
-
Error boundaries preserve the declarative nature of React, and behave as you would expect. For example, even if an error occurs in a `componentDidUpdate`method caused by a `setState` somewhere deep in the tree, it will still correctly propagate to the closest error boundary.
124
+
גובלי שגיאות משמרים את האופן הדקלרטיבי של React ומספקים התנהגות דומה. לדוגמא, אפילו אם שגיאה צצה במתודת ה-`componentDidUpdate`שנגרמה איפשהו עמוק בתוך העץ בתוך `setState`, היא תוצף לגובל השגיאות הקרוב ביותר.
125
125
126
-
## How About Event Handlers? {#how-about-event-handlers}
126
+
## מה עם מטפלי אירועים? {#how-about-event-handlers}
גובלי שגיאות**לא**תופסים שגיאות מתוך מטפלי אירועים.
129
129
130
-
React doesn't need error boundaries to recover from errors in event handlers. Unlike the render method and lifecycle methods, the event handlers don't happen during rendering. So if they throw, React still knows what to display on the screen.
130
+
React לא צריך גובלי שגיאות כדי להתאושש משגיאות במטפלי אירועים. בשונה מהמתודת הרינדור ומתודות מחזור החיים, שגיאות שצצות במטפלי האירועים לא קורות בזמן הרינדור. אז אם צצה שגיאה, React עדיין ידע מה להציג.
131
+
132
+
כשיש צורך לתפוס שגיאה במטפל האירועים, השתמשו בבלוק ה-`try` / `catch` כרגיל:
131
133
132
-
If you need to catch an error inside event handler, use the regular JavaScript `try` / `catch` statement:
133
134
134
135
```js{9-13,17-20}
135
136
class MyComponent extends React.Component {
@@ -141,7 +142,7 @@ class MyComponent extends React.Component {
141
142
142
143
handleClick() {
143
144
try {
144
-
// Do something that could throw
145
+
// קוד שזורק שגיאה
145
146
} catch (error) {
146
147
this.setState({ error });
147
148
}
@@ -156,10 +157,10 @@ class MyComponent extends React.Component {
156
157
}
157
158
```
158
159
159
-
Note that the above example is demonstrating regular JavaScript behavior and doesn't use error boundaries.
160
+
שימו לב שהדוגמא הנ״ל מדגימה קוד JavaScript סטנדרטי לטיפול בשגיאות ולא קשורה בשום אופן לגבולות שגיאות.
160
161
161
-
## Naming Changes from React 15 {#naming-changes-from-react-15}
162
+
## שינוי שם מגרסה 15 {#naming-changes-from-react-15}
162
163
163
-
React 15 included a very limited support for error boundaries under a different method name: `unstable_handleError`. This method no longer works, and you will need to change it to `componentDidCatch`in your code starting from the first 16 beta release.
164
+
גרסה 15 של React כללה תמיכה מוגבלת ביותר לגבולות שגיאות תחת מתודה בשם אחר: `unstable_handleError`. המתודה הזאת כבר לא נתמכת, ותאלצו לשנות אותה ל- `componentDidCatch`בקוד שלכם החל מגרסת הביתא הראשונה של React 16.
164
165
165
-
For this change, we’ve provided a [codemod](https://github.com/reactjs/react-codemod#error-boundaries)to automatically migrate your code.
166
+
בשביל השינוי הזה, כללנו [משנה קוד (codemod)](https://github.com/reactjs/react-codemod#error-boundaries)כדי לעדכן באופן אוטומטי את הקוד הרלוונטי.
0 commit comments