reactjs / reactjs/react.dev

[Suggestion]: Section from useContext might not be entirely accurate

Aberta Para iniciantes
#6,739 1 comentário 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

type: documentation
Linguagem predominante
JavaScript
Estrelas
11.8k
Forks
7.9k
Merge médio
1d 11h
PRs com merge (30d)
11

Descrição

Summary

There is a paragraph about re-rendering of children when parent re-renders which doesn't seem to be accurate, see below.

Page

https://react.dev/reference/react/useContext#optimizing-re-renders-when-passing-objects-and-functions

Details

Here: https://react.dev/reference/react/useContext#optimizing-re-renders-when-passing-objects-and-functions,
it says in the bottom of the section:

As a result of this change, even if MyApp needs to re-render, the components calling useContext(AuthContext) won’t need to re-render unless currentUser has changed.

This is not entirely true. because if MyApp re-renders, all of its children (including those consuming the context) will re-render by default, regardless if currentUser has changed or not. Unless there was React.memo used - but this is not mentioned in that part of the docs.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Abra a referência de useContext na seção “Optimizing re-renders when passing objects and functions” e revise a afirmação citada sobre a nova renderização de MyApp. Verifique o comportamento descrito ali, depois revise a documentação para que suas condições de nova renderização estejam corretas e execute as verificações da documentação antes de enviar.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, react
Domínio
documentation
Tipo de issue
Documentação
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
62/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.