Skip to content

Update hooks-reference.md #117

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

Merged
merged 2 commits into from
Jul 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Przyjmuje obiekt kontekstu (wartość zwróconą przez `React.createContext`) i

Kiedy najbliższy rodzic `<MyContext.Provider>` zostanie zaktualizowany, ten hook wywoła ponowne renderowanie komponentu z najnowszym kontekstem `value` przekazanym dostawcy (ang. *provider*) `MyContext`.

Pamiętaj, że argument przekazany do `useContest` musi być *samym obiektem kontekstu*:
Pamiętaj, że argument przekazany do `useContext` musi być *samym obiektem kontekstu*:

* **Poprawnie:** `useContext(MyContext)`
* **Niepoprawnie:** `useContext(MyContext.Consumer)`
Expand All @@ -205,7 +205,7 @@ Poniższe hooki są albo są wariantami tych podstawowych, z poprzedniego podr
const [state, dispatch] = useReducer(reducer, initialArg, init);
```

Alternatywa dla hooka [`useState`](#usestate). Przyjmuje reduktor (ang *reducer*), będący funkcją o sygnaturze `(stan, akcja) => nowyStan`, a zwraca aktualny stan w parze z metodą `dispatch`. (Jeżeli znasz bibliotekę Redux, wiesz już, jak to działa.)
Alternatywa dla hooka [`useState`](#usestate). Przyjmuje reduktor (ang. *reducer*), będący funkcją o sygnaturze `(stan, akcja) => nowyStan`, a zwraca aktualny stan w parze z metodą `dispatch`. (Jeżeli znasz bibliotekę Redux, wiesz już, jak to działa.)

`useReducer` sprawdza się lepiej od `useState` tam, gdzie występuje skomplikowana logika związana ze stanem, obejmująca wiele pod-wartości lub gdy następny stan zależy od poprzedniego. `useReducer` pozwala też zoptymalizować wydajność komponentów uruchamiających głębokie aktualizacje, ponieważ zamiast przekazywać funkcje zwrotne (ang. *callback*), [możesz przekazać funkcję `dispatch` w dół drzewa](/docs/hooks-faq.html#how-to-avoid-passing-callbacks-down).

Expand Down