From e9620a99a6a10c6dc81650db05889f16a6d366c9 Mon Sep 17 00:00:00 2001 From: Gasim Gasimzada Date: Fri, 11 Oct 2019 14:27:57 +0400 Subject: [PATCH 1/2] Translate Uncontrolled Components --- content/docs/uncontrolled-components.md | 40 +++++++++---------- .../input-type-file.js | 6 +-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/content/docs/uncontrolled-components.md b/content/docs/uncontrolled-components.md index 10b6eab28..1be341ed4 100644 --- a/content/docs/uncontrolled-components.md +++ b/content/docs/uncontrolled-components.md @@ -1,14 +1,14 @@ --- id: uncontrolled-components -title: Uncontrolled Components +title: Kontrolsuz Komponentlər permalink: docs/uncontrolled-components.html --- -In most cases, we recommend using [controlled components](/docs/forms.html) to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself. +Biz çox halda, anketləri tətbiq etmək üçün [kontrol olunan komponentlər](/docs/forms.html) işlətməyi tövsiyyə edirik. Kontrol olunan komponentlərdə anket məlumatları React komponenti tərəfindən idarə olunur. Buna alternativ kontrolsuz komponentlərdir. Bu komponentlərdə anket məlumatları DOM tərəfindən idarə olunur. -To write an uncontrolled component, instead of writing an event handler for every state update, you can [use a ref](/docs/refs-and-the-dom.html) to get form values from the DOM. +Kontrolsuz komponent yazmaq üçün bütün state yenilikləri üçün hadisə işləyiciləri yazmaq əvəzinə DOM-dan anket dəyərlərini almaq üçün [ref-dən istifadə edə bilərsiniz](/docs/refs-and-the-dom.html). -For example, this code accepts a single name in an uncontrolled component: +Məsələn, açağıdakı kodda kontrol olunmayan komponent birtək ad qəbul edir: ```javascript{5,9,18} class NameForm extends React.Component { @@ -19,7 +19,7 @@ class NameForm extends React.Component { } handleSubmit(event) { - alert('A name was submitted: ' + this.input.current.value); + alert('Göndərilən ad: ' + this.input.current.value); event.preventDefault(); } @@ -27,56 +27,56 @@ class NameForm extends React.Component { return (
- +
); } } ``` -[**Try it on CodePen**](https://codepen.io/gaearon/pen/WooRWa?editors=0010) +[**CodePen-də sınayın**](https://codepen.io/gaearon/pen/WooRWa?editors=0010) -Since an uncontrolled component keeps the source of truth in the DOM, it is sometimes easier to integrate React and non-React code when using uncontrolled components. It can also be slightly less code if you want to be quick and dirty. Otherwise, you should usually use controlled components. +Kontrolsuz komponentlərdə həqiqət mənbəyi DOM-da saxlanır. Bu səbədən React və React olmayan kodları kontrol komponentlərdən istifadə edərək inteqrasiya etmək daha asandır. Tez kod yazmaq üçün kontrolsuz komponentlər daha az koda səbəb ola bilər. Əks halda, kontrol olunan komponentlərdən istifadə edin. -If it's still not clear which type of component you should use for a particular situation, you might find [this article on controlled versus uncontrolled inputs](https://goshakkk.name/controlled-vs-uncontrolled-inputs-react/) to be helpful. +Əgər xüsusi vəziyyətdə hansı tipli komponenti işlətməyi bilmirsinizsə [kontrol olunan və kontrolsuz anket sahələrinin müqayisəsi yazını](https://goshakkk.name/controlled-vs-uncontrolled-inputs-react/) faydalı tapa bilərsiniz. -### Default Values {#default-values} +### Təyin Olunmayan Dəyərlər {#default-values} -In the React rendering lifecycle, the `value` attribute on form elements will override the value in the DOM. With an uncontrolled component, you often want React to specify the initial value, but leave subsequent updates uncontrolled. To handle this case, you can specify a `defaultValue` attribute instead of `value`. +React-in render zamanı, anket elementlərinin `value` atribut dəyəri DOM dəyərlərininin üzərindən yazılacaq. Kontrolsuz komponentlərdə təyin olunmayan dəyərlərin React tərəfindən bildirilməsini, sonrakı yeniliklərin isə kontrolsuz olmasını istəyə bilərsiniz. Bu ssenari üçün `value` atributu yerinə `defaultValue` atributundan istifadə edə bilərsiniz. ```javascript{7} render() { return (
- +
); } ``` -Likewise, `` and `` support `defaultChecked`, and `