Skip to content

Commit 44b25b0

Browse files
pmartyniakjakubdrozdek
pmartyniak
andcommitted
Translate 'Refs Must Have Owner Warning' page
Co-Authored-By: Jakub Drozdek <30927218+jakubdrozdek@users.noreply.github.com>
1 parent 2c42043 commit 44b25b0

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

content/warnings/refs-must-have-owner.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,47 @@ layout: single
44
permalink: warnings/refs-must-have-owner.html
55
---
66

7-
You are probably here because you got one of the following error messages:
7+
Jesteś tu najprawdopodobniej z powodu jednego z dwóch błędów:
88

99
*React 16.0.0+*
1010
> Warning:
1111
>
1212
> Element ref was specified as a string (myRefName) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).
1313
14-
*earlier versions of React*
14+
*wcześniejsze wersje Reacta*
1515
> Warning:
1616
>
1717
> addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded.
1818
19-
This usually means one of three things:
19+
Zazwyczaj oznacza to jedną z trzech rzeczy:
2020

21-
- You are trying to add a `ref` to a function component.
22-
- You are trying to add a `ref` to an element that is being created outside of a component's render() function.
23-
- You have multiple (conflicting) copies of React loaded (eg. due to a misconfigured npm dependency)
21+
- Usiłujesz dodać referencję (`ref`) do komponentu funkcyjnego.
22+
- Próbujesz dodać referencję do elementu, który jest tworzony poza metodą `render` komponentu.
23+
- Masz załadowanych kilka (konfliktujących) wersji Reacta (np. z powodu źle skonfigurowanych zależności npm).
2424

25-
## Refs on Function Components {#refs-on-function-components}
25+
## Referencje do komponentów funkcyjnych {#refs-on-function-components}
2626

27-
If `<Foo>` is a function component, you can't add a ref to it:
27+
Jeśli `<Foo>` jest komponentem funkcyjnym, nie możesz tworzyć do niego referencji:
2828

2929
```js
30-
// Doesn't work if Foo is a function!
30+
// nie zadziała, jeśli Foo jest funkcją!
3131
<Foo ref={foo} />
3232
```
3333

34-
If you need to add a ref to a component, convert it to a class first, or consider not using refs as they are [rarely necessary](/docs/refs-and-the-dom.html#when-to-use-refs).
34+
Jeśli musisz dodać referencję do komponentu, zamień go najpierw na klasę lub rozważ, [czy na pewno potrzebujesz referencji](/docs/refs-and-the-dom.html#when-to-use-refs).
3535

36-
## Strings Refs Outside the Render Method {#strings-refs-outside-the-render-method}
36+
## Referencje tekstowe poza metodą render {#strings-refs-outside-the-render-method}
3737

38-
This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's `render` method). For example, this won't work:
38+
Oznacza to najczęściej, że próbujesz dodać referencję do komponentu, który nie ma "właściciela"
39+
(czyli nie został stworzony wewnątrz metody `render` innego komponentu). Na przykład to nie zadziała:
3940

4041
```js
41-
// Doesn't work!
42+
// Nie działa!
4243
ReactDOM.render(<App ref="app" />, el);
4344
```
4445

45-
Try rendering this component inside of a new top-level component which will hold the ref. Alternatively, you may use a callback ref:
46+
Spróbuj wyrenderować komponent wewnątrz jakiegoś komponentu-rodzica, który będzie przechowywać referencję.
47+
Możesz też użyć funkcji zwrotnej (ang. *callback*):
4648

4749
```js
4850
let app;
@@ -54,10 +56,13 @@ ReactDOM.render(
5456
);
5557
```
5658

57-
Consider if you [really need a ref](/docs/refs-and-the-dom.html#when-to-use-refs) before using this approach.
59+
Zanim zdecydujesz się na takie rozwiązanie, upewnij się, [czy na pewno potrzebujesz referencji](/docs/refs-and-the-dom.html#when-to-use-refs).
5860

59-
## Multiple copies of React {#multiple-copies-of-react}
61+
## Wiele kopii Reacta {#multiple-copies-of-react}
6062

61-
Bower does a good job of deduplicating dependencies, but npm does not. If you aren't doing anything (fancy) with refs, there is a good chance that the problem is not with your refs, but rather an issue with having multiple copies of React loaded into your project. Sometimes, when you pull in a third-party module via npm, you will get a duplicate copy of the dependency library, and this can create problems.
63+
Bower dobrze radzi sobie z usuwaniem zduplikowanych zależności, ale npm już nie.
64+
Jeśli nie robisz nic (szczególnego) z referencjami, jest spora szansa, że problem nie leży postronie Twoich referencji,
65+
a raczej w tym, że w Twoim projekcie znalazła się więcej niż jedna instancja Reacta. Czasem zaciągając zewnętrzny moduł z npm otrzymasz dodatkową kopię Reacta w bibliotece zależności.
66+
Może to powodować problemy.
6267

63-
If you are using npm... `npm ls` or `npm ls react` might help illuminate.
68+
Jeśli używasz npm... `npm ls` albo `npm ls react` mogą rzucić trochę światła na problem.

0 commit comments

Comments
 (0)