Rescreva essa parte da string com as seguintes condições: 1. Não elimine NENHUMA…
- User
Rescreva essa parte da string com as seguintes condições: 1. Não elimine NENHUMA informação dada no artigo. 2. Conceitos, expressões ou referências devem ser mantidas em inglês. 3. Apenas transcreva o artigo para português brasileiro, dentro de seu contexto. 4. Não remova as tags HTML e nem os "#thedivisor#". 5. Você deve me enviar sua resposta em texto puro, sem markdown.
#thedivisor#Currently your app renders correctly with props and state flowing down the hierarchy. But to change the state according to user input, you will need to support data flowing the other way: the form components deep in the hierarchy need to update the state in <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">FilterableProductTable</code>.#thedivisor#React makes this data flow explicit, but it requires a little more typing than two-way data binding. If you try to type or check the box in the example above, you’ll see that React ignores your input. This is intentional. By writing <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><input value={filterText} /></code>, you’ve set the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">value</code> prop of the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">input</code> to always be equal to the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">filterText</code> state passed in from <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">FilterableProductTable</code>. Since <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">filterText</code> state is never set, the input never changes.#thedivisor#You want to make it so whenever the user changes the form inputs, the state updates to reflect those changes. The state is owned by <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">FilterableProductTable</code>, so only it can call <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">setFilterText</code> and <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">setInStockOnly</code>. To let <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">SearchBar</code> update the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">FilterableProductTable</code>’s state, you need to pass these functions down to <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">SearchBar</code>:#thedivisor#Inside the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">SearchBar</code>, you will add the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">onChange</code> event handlers and set the parent state from them:#thedivisor#Now the application fully works! - Assistant
#thedivisor#Atualmente, seu aplicativo renderiza corretamente com as props e o estado fluindo pela hierarquia. Mas, para mudar o estado de acordo com a entrada do usuário, você precisará suportar a passagem de dados na outra direção: os componentes do formulário, que estão profundos na hierarquia, precisam atualizar o estado em FilterableProductTable.#thedivisor#O React torna esse fluxo de dados explícito, mas requer um pouco mais de digitação do que a ligação de dados bidirecional. Se você tentar digitar ou marcar a caixa no exemplo acima, verá que o React ignora sua entrada. Isso é intencional. Ao escrever <input value={filterText} />, você definiu a prop value do input para sempre ser igual ao estado filterText passado de FilterableProductTable. Como o estado filterText nunca é definido, o input nunca muda.#thedivisor#Você quer que, sempre que o usuário alterar as entradas do formulário, o estado seja atualizado para refletir essas mudanças. O estado é de propriedade de FilterableProductTable, então somente ele pode chamar setFilterText e setInStockOnly. Para permitir que SearchBar atualize o estado do FilterableProductTable, você precisa passar essas funções para SearchBar:#thedivisor#Dentro do SearchBar, você adicionará os manipuladores de evento onChange e definirá o estado do pai a partir deles:#thedivisor#Agora o aplicativo funciona totalmente!