Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation Conditional rendering #22

Merged
merged 2 commits into from
Aug 3, 2023
Merged

Conversation

zubialevich
Copy link
Collaborator

Пераклад артыкула "Умоўны рэндэрынг"

@github-actions
Copy link

github-actions bot commented Jul 28, 2023

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link
Collaborator

@bielarusajed bielarusajed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Акрамя гэтых заўваг, напамінаю пра «двукоссі»


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`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Унутры React кампанентаў

Гляджу, у нас пачалося разыходжанне паміж "React кампанент" і "кампанент React". Асабіста мне падаецца, тут лепш было б другое. Але наогул трэба будзе куды-небудзь пазначыць праверку аднароднасці вось у такіх выпадках як асобную глабальную задачу.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А ці ёсць розніца? Ці гэта пытанне стылю? Але наконт аднароднасці згодны) Будзе цудоўна зрабіць стайл гайд і прайсціся з ім пасля па перакладзенаму

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пытанне стылю. Але тут так, стайл гайд трэба спачатку.


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` замест трох умоў `? :`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@belarusaed ці трэба тут (можа быць "tea" або "coffee") абгортваць у « ці пакінуць "?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, тут жа двукоссі як кавалак коду, таму хай застаюцца такія.

@bielarusajed
Copy link
Collaborator

А, ой, заўвагі пазначаныя вырашанымі, а зменаў няма…

@zubialevich
Copy link
Collaborator Author

хех, гэта я заўвагі пазначыў лакальна, а змены не запушыў) Павінны з'явіцца

@zubialevich zubialevich merged commit d574903 into main Aug 3, 2023
@zubialevich zubialevich deleted the conditional-rendering branch August 3, 2023 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants