Conversation
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
bielarusajed
left a comment
There was a problem hiding this comment.
Акрамя гэтых заўваг, напамінаю пра «двукоссі»
| ### Лагічны аператар І (`&&`) {/*logical-and-operator-*/} | ||
|
|
||
| Another common shortcut you'll encounter is the [JavaScript logical AND (`&&`) operator.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#:~:text=The%20logical%20AND%20(%20%26%26%20)%20operator,it%20returns%20a%20Boolean%20value.) Inside React components, it often comes up when you want to render some JSX when the condition is true, **or render nothing otherwise.** With `&&`, you could conditionally render the checkmark only if `isPacked` is `true`: | ||
| Яшчэ адно часта сустракаемае скарачэнне ў JavaScript — гэта [лагічны аператар І (`&&`).](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#:~:text=The%20logical%20AND%20(%20%26%26%20)%20operator,it%20returns%20a%20Boolean%20value.) Унутры React кампанентаў ён часта выкарыстоўваецца, калі вам трэба адрэндэрыць нейкі JSX, калі ўмова роўная `true`, **або нічога не рэндэрыць інакш.** З дапамогай `&&` вы можаце ўмоўна рэндэрыць «птушку», толькі калі `isPacked` мае значэнне `true`: |
There was a problem hiding this comment.
Унутры React кампанентаў
Гляджу, у нас пачалося разыходжанне паміж "React кампанент" і "кампанент React". Асабіста мне падаецца, тут лепш было б другое. Але наогул трэба будзе куды-небудзь пазначыць праверку аднароднасці вось у такіх выпадках як асобную глабальную задачу.
There was a problem hiding this comment.
А ці ёсць розніца? Ці гэта пытанне стылю? Але наконт аднароднасці згодны) Будзе цудоўна зрабіць стайл гайд і прайсціся з ім пасля па перакладзенаму
There was a problem hiding this comment.
Пытанне стылю. Але тут так, стайл гайд трэба спачатку.
| #### Замяніце шэраг тэрнарных аператараў `? :` на `if` і пераменныя {/*refactor-a-series-of---to-if-and-variables*/} | ||
|
|
||
| This `Drink` component uses a series of `? :` conditions to show different information depending on whether the `name` prop is `"tea"` or `"coffee"`. The problem is that the information about each drink is spread across multiple conditions. Refactor this code to use a single `if` statement instead of three `? :` conditions. | ||
| Кампанент `Drink` выкарыстоўвае шэраг умоў `? :` для паказу рознай інфармацыі ў залежнасці ад значэння пропса `name` (можа быць `"tea"` або `"coffee"`). Праблема заключаецца ў тым, што інфармацыя аб кожным напоі раскідана па некалькіх умовах. Перапішыце код так, каб выкарыстоўваўся толькі адзін аператар `if` замест трох умоў `? :`. |
There was a problem hiding this comment.
@belarusaed ці трэба тут (можа быць "tea" або "coffee") абгортваць у « ці пакінуць "?
There was a problem hiding this comment.
Не, тут жа двукоссі як кавалак коду, таму хай застаюцца такія.
|
А, ой, заўвагі пазначаныя вырашанымі, а зменаў няма… |
|
хех, гэта я заўвагі пазначыў лакальна, а змены не запушыў) Павінны з'явіцца |
Пераклад артыкула "Умоўны рэндэрынг"