From 46a203956ca53e0eb69e716888c9194926278916 Mon Sep 17 00:00:00 2001 From: Matheus Clark dos Santos Monte Date: Fri, 8 Feb 2019 17:07:39 -0400 Subject: [PATCH 1/3] Translate page dont-call-proptypes.md to Pt-BR Signed-off-by: Matheus Clark dos Santos Monte --- content/warnings/dont-call-proptypes.md | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/content/warnings/dont-call-proptypes.md b/content/warnings/dont-call-proptypes.md index 07dfa33f0..ce58f1de9 100644 --- a/content/warnings/dont-call-proptypes.md +++ b/content/warnings/dont-call-proptypes.md @@ -6,15 +6,15 @@ permalink: warnings/dont-call-proptypes.html > Note: > -> `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). +> `React.PropTypes` foi movido para um pacote diferente desde a versão v15.5. do React. Por favor, use [the `prop-types` library agora](https://www.npmjs.com/package/prop-types). > ->We provide [a codemod script](/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes) to automate the conversion. +>Nós fornecemos [um script de migração](/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes) para automatizar o processo. -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. +Em releases futuras do React, o código que implementa a validação de PropType será removida. Uma vez isso acontecendo, qualquer código que contenha essas funções chamadas de forma manual irão emitir um erro. -### Declaring PropTypes is still fine {#declaring-proptypes-is-still-fine} +### Declarar PropTypes ainda é uma boa ideia {#declaring-proptypes-is-still-fine} -The normal usage of PropTypes is still supported: +A forma normal de usar a PropTypes ainda é suportada: ```javascript Button.propTypes = { @@ -22,11 +22,11 @@ Button.propTypes = { }; ``` -Nothing changes here. +Nada mudou por aqui. -### Don’t call PropTypes directly {#dont-call-proptypes-directly} +### Não chame PropTypes diretamente {#dont-call-proptypes-directly} -Using PropTypes in any other way than annotating React components with them is no longer supported: +Usar PropTypes de uma forma diferente que não seja a anotação dos componentes React não é mais suportado: ```javascript var apiShape = PropTypes.shape({ @@ -34,34 +34,34 @@ var apiShape = PropTypes.shape({ statusCode: PropTypes.number.isRequired }).isRequired; -// Not supported! +// Não suportado var error = apiShape(json, 'response'); ``` -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). +Caso você tenha a dependência de usar PropTypes dessa forma, encorajamos você a usar ou criar um fork da PropTypes (como [esses](https://github.com/aackerman/PropTypes) [dois](https://github.com/developit/proptypes) pacotes). -If you don't fix the warning, this code will crash in production with React 16. +Se você não resolver esse warning, Esse código não irá funcionar em produção com o React 16. -### If you don't call PropTypes directly but still get the warning {#if-you-dont-call-proptypes-directly-but-still-get-the-warning} +### Se você não chama PropTypes diretamente mas mesmo assim recebe esse warning {#if-you-dont-call-proptypes-directly-but-still-get-the-warning} -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: +Inspecione a stack trace produzida pelo warning. Você irá encontrar a definição do componente responsável pela chamada direta da PropTypes. Provavelmente, o problema é causado por uma PropTypes de terceiros que encapsula a PropTypes do React, por exemplo: ```js Button.propTypes = { highlighted: ThirdPartyPropTypes.deprecated( PropTypes.bool, - 'Use `active` prop instead' + 'Use `active` prop ao invés disso' ) } ``` -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. +Nesse caso, `ThirdPartyPropTypes.deprecated` é um wrapper chamando `PropTypes.bool`. Esse padrão por si só já é o suficiente, mas dispara um falso positivo pelo fato do React pensar que está chamando diretamente a PropTypes. No próximo tópico, iremos explicar como resolver esse problema para a implementação de uma biblioteca, algo como `ThirdPartyPropTypes`. Caso não seja uma biblioteca que você escreveu, você pode abrir um issue por isso. -### Fixing the false positive in third party PropTypes {#fixing-the-false-positive-in-third-party-proptypes} +### Resolvendo o falso positivo em uma PropTypes de terceiro {#fixing-the-false-positive-in-third-party-proptypes} -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. +Se você é o autor de uma biblioteca terceira com PropTypes e permite que seus usuários façam wrap de uma React PropTypes existente, provavelmente eles começarão a receber esse warning da sua biblioteca. Isso acontece porque o React não enxerga um último parâmetro "secreto" que passa a [detectar](https://github.com/facebook/react/pull/7132) manualmente as chamadas da PropTypes. -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: +Aqui está como corrigir isso. Usaremos `deprecated` daqui [react-bootstrap/react-prop-types](https://github.com/react-bootstrap/react-prop-types/blob/0d1cd3a49a93e513325e3258b28a82ce7d38e690/src/deprecated.js) como exemplo. A atual implementação só passa adiante as `props`, `propName`, and `componentName` arguments: ```javascript export default function deprecated(propType, explanation) { @@ -79,7 +79,7 @@ export default function deprecated(propType, explanation) { } ``` -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: +Para resolver o falso positivo, tenha certeza que está passando **todos** os parâmetro para o wrapped da PropType. Um jeito fácil de fazer isso com ES6 é usando a notação `...rest`: ```javascript export default function deprecated(propType, explanation) { @@ -97,4 +97,4 @@ export default function deprecated(propType, explanation) { } ``` -This will silence the warning. +Isso fará com que o warning pare de ser lançado. From 0931f6491b20c0d83286fc84d79428a35696efd9 Mon Sep 17 00:00:00 2001 From: Matheus Clark dos Santos Monte Date: Fri, 8 Feb 2019 17:35:28 -0400 Subject: [PATCH 2/3] Change translate to suggestion in line #43 Signed-off-by: Matheus Clark dos Santos Monte --- content/warnings/dont-call-proptypes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/warnings/dont-call-proptypes.md b/content/warnings/dont-call-proptypes.md index ce58f1de9..384dbb9b1 100644 --- a/content/warnings/dont-call-proptypes.md +++ b/content/warnings/dont-call-proptypes.md @@ -38,7 +38,7 @@ var apiShape = PropTypes.shape({ var error = apiShape(json, 'response'); ``` -Caso você tenha a dependência de usar PropTypes dessa forma, encorajamos você a usar ou criar um fork da PropTypes (como [esses](https://github.com/aackerman/PropTypes) [dois](https://github.com/developit/proptypes) pacotes). +Caso você dependa do uso PropTypes dessa forma, encorajamos você a usar ou criar um fork da PropTypes (como [esses](https://github.com/aackerman/PropTypes) [dois](https://github.com/developit/proptypes) pacotes). Se você não resolver esse warning, Esse código não irá funcionar em produção com o React 16. From de621736ac1978011fee0d68aa6e569a5806fd10 Mon Sep 17 00:00:00 2001 From: Matheus Clark dos Santos Monte Date: Fri, 8 Feb 2019 17:39:57 -0400 Subject: [PATCH 3/3] Add modifies to line #41 #43 #45 Signed-off-by: Matheus Clark dos Santos Monte --- content/warnings/dont-call-proptypes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/warnings/dont-call-proptypes.md b/content/warnings/dont-call-proptypes.md index 384dbb9b1..1f071abdb 100644 --- a/content/warnings/dont-call-proptypes.md +++ b/content/warnings/dont-call-proptypes.md @@ -40,11 +40,11 @@ var error = apiShape(json, 'response'); Caso você dependa do uso PropTypes dessa forma, encorajamos você a usar ou criar um fork da PropTypes (como [esses](https://github.com/aackerman/PropTypes) [dois](https://github.com/developit/proptypes) pacotes). -Se você não resolver esse warning, Esse código não irá funcionar em produção com o React 16. +Se você não corrigir esse alerta, esse código não funcionará em produção com o React 16. -### Se você não chama PropTypes diretamente mas mesmo assim recebe esse warning {#if-you-dont-call-proptypes-directly-but-still-get-the-warning} +### Se você não chama PropTypes diretamente mas mesmo assim recebe esse alerta {#if-you-dont-call-proptypes-directly-but-still-get-the-warning} -Inspecione a stack trace produzida pelo warning. Você irá encontrar a definição do componente responsável pela chamada direta da PropTypes. Provavelmente, o problema é causado por uma PropTypes de terceiros que encapsula a PropTypes do React, por exemplo: +Inspecione a stack trace produzida pelo alerta. Você encontrará a definição do componente responsável pela chamada direta da PropTypes. Provavelmente, o problema é causado por uma PropTypes de terceiros que encapsula a PropTypes do React, por exemplo: ```js Button.propTypes = {