You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/warnings/dont-call-proptypes.md
+26-22
Original file line number
Diff line number
Diff line change
@@ -4,47 +4,48 @@ layout: single
4
4
permalink: warnings/dont-call-proptypes.html
5
5
---
6
6
7
-
> Note:
7
+
> Uwaga:
8
8
>
9
-
> `React.PropTypes`has moved into a different package since React v15.5. Please use [the`prop-types` library instead](https://www.npmjs.com/package/prop-types).
9
+
> Z wersją React v15.5 `React.PropTypes`zostało przeniesione do innej paczki. Zamiast importować z paczki Reacta, używaj [biblioteki`prop-types`](https://www.npmjs.com/package/prop-types).
10
10
>
11
-
>We provide [a codemod script](/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes) to automate the conversion.
In a future major release of React, the code that implements PropType validation functions will be stripped in production. Once this happens, any code that calls these functions manually (that isn't stripped in production) will throw an error.
13
+
W przyszłych wersjach Reacta kod, który implementuje funkcje walidujące PropTypes będzie wycinany na produkcji. Gdy to nastąpi, każdy kod wywoujący te funkcje bezpośrednio będzie powodował błąd (o ile także nie zostanie wycięty na produkcji).
14
14
15
-
### Declaring PropTypes is still fine {#declaring-proptypes-is-still-fine}
15
+
### Definiowanie PropTypes pozostaje prawidłowe {#declaring-proptypes-is-still-fine}
### Nie wywołuj PropTypes bezpośrednio {#dont-call-proptypes-directly}
28
28
29
-
Using PropTypes in any other way than annotating React components with them is no longer supported:
29
+
Używanie PropTypes w jakikolwiek inny sposób, niż do opisywania komponentów, nie będzie już wspierane:
30
30
31
31
```javascript
32
32
var apiShape =PropTypes.shape({
33
33
body:PropTypes.object,
34
34
statusCode:PropTypes.number.isRequired
35
35
}).isRequired;
36
36
37
-
//Not supported!
37
+
//Brak wsparcia!
38
38
var error =apiShape(json, 'response');
39
39
```
40
40
41
-
If you depend on using PropTypes like this, we encourage you to use or create a fork of PropTypes (such as [these](https://github.com/aackerman/PropTypes)[two](https://github.com/developit/proptypes) packages).
41
+
Jeżeli logika twojej aplikacji jest uzależniona od użycia PropTypes w taki sposób, zachęcamy do stworzenia forka PropTypes lub użycia jednego z już istniejących (np. któregoś z [tych](https://github.com/aackerman/PropTypes)[dwóch](https://github.com/developit/proptypes)).
42
42
43
-
If you don't fix the warning, this code will crash in production with React 16.
43
+
Jeśli zignorujesz to ostrzeżenie, po aktualizacji Reacta do wersji 16 możesz spodziewać się krytycznych błędów na środowisku produkcyjnym.
44
44
45
-
### If you don't call PropTypes directly but still get the warning {#if-you-dont-call-proptypes-directly-but-still-get-the-warning}
45
+
### Ostrzeżenie pojawia się, mimo że nie wywołujesz PropTypes bezpośrednio {#if-you-dont-call-proptypes-directly-but-still-get-the-warning}
46
46
47
-
Inspect the stack trace produced by the warning. You will find the component definition responsible for the PropTypes direct call. Most likely, the issue is due to third-party PropTypes that wrap React’s PropTypes, for example:
47
+
Przyjrzyj się stosowi wywołań, który wyświetla się wraz z ostrzeżeniem. Znajdziesz w nim nazwę komponentu odpowiedzialnego za bezpośrednie wywołanie PropTypes.
48
+
Prawdopodobnie problem jest spowodowany przez zewnętrzną bibiliotekę, która opakowuje PropTypes. Przykładowo:
48
49
49
50
```js
50
51
Button.propTypes= {
@@ -55,13 +56,16 @@ Button.propTypes = {
55
56
}
56
57
```
57
58
58
-
In this case, `ThirdPartyPropTypes.deprecated` is a wrapper calling `PropTypes.bool`. This pattern by itself is fine, but triggers a false positive because React thinks you are calling PropTypes directly. The next section explains how to fix this problem for a library implementing something like `ThirdPartyPropTypes`. If it's not a library you wrote, you can file an issue against it.
59
+
Taki wzorzec sam w sobie jest w porządku, lecz powoduje on fałszywe ostrzeżenie, ponieważ React "myśli", że PropTypes wywoływane jest bezpośrednio.
60
+
W następnej sekcji przeczytasz, jak uporać się z takim ostrzeżeniem będąc autorem biblioteki, w której pojawia się implementacja czegoś podobnego do `ThirdPartyPropTypes`. Jeśli ostrzeżenie pochodzi z biblioteki, której nie jesteś autorem, możesz zgłosić błąd jej autorom.
59
61
60
-
### Fixing the false positive in third party PropTypes {#fixing-the-false-positive-in-third-party-proptypes}
62
+
### Jak poprawić fałszywe ostrzeżenie w zewnętrznych PropTypes {#fixing-the-false-positive-in-third-party-proptypes}
61
63
62
-
If you are an author of a third party PropTypes library and you let consumers wrap existing React PropTypes, they might start seeing this warning coming from your library. This happens because React doesn't see a "secret" last argument that [it passes](https://github.com/facebook/react/pull/7132) to detect manual PropTypes calls.
64
+
Jeśli jesteś autorem biblioteki operującej na PropTypes i pozwalasz użytkownikom na opakowywanie istniejących PropTypes, mogą oni natknąć się na ostrzeżenia pochodzące z twojej biblioteki.
65
+
Dzieje się tak, gdyż React nie widzi ostatniego, „ukrytego” parametru, [który jest przekazywany](https://github.com/facebook/react/pull/7132) po to, by wykryć bezpośrednie użycie PropTypes.
63
66
64
-
Here is how to fix it. We will use `deprecated` from [react-bootstrap/react-prop-types](https://github.com/react-bootstrap/react-prop-types/blob/0d1cd3a49a93e513325e3258b28a82ce7d38e690/src/deprecated.js) as an example. The current implementation only passes down the `props`, `propName`, and `componentName` arguments:
67
+
Oto, jak temu zaradzić. Jako przykładu użyjemy `deprecated` z [react-bootstrap/react-prop-types](https://github.com/react-bootstrap/react-prop-types/blob/0d1cd3a49a93e513325e3258b28a82ce7d38e690/src/deprecated.js).
68
+
Obecna implementacja przekazuje tylko `props`, `propName` i `componentName`:
@@ -79,11 +83,11 @@ export default function deprecated(propType, explanation) {
79
83
}
80
84
```
81
85
82
-
In order to fix the false positive, make sure you pass **all**arguments down to the wrapped PropType. This is easy to do with the ES6 `...rest` notation:
86
+
Aby pozbyć się błędnego ostrzeżenia, upewnij się, że przekazujesz **wszystkie**argumenty do opakowanego PropType. Łatwo to zrobić przy pomocy notacji ES6 `…rest`:
0 commit comments