[Suggestion]: Add some elaboration to the docs for TypeScript DOM events and Pure Functions
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- JavaScript
- Estrelas
- 11.8k
- Forks
- 7.9k
- Merge médio
- 1d 11h
- PRs com merge (30d)
- 11
Descrição
Summary
The Section on DOM events in the page Using TypeScript, mentions extracting functions, this can be elaborated further to include the case where we do get the types i.e. inline methods.
The section on Pure Functions contain a example of Teacups and guests, the global let guests variable should be incremented by 1, but is incremented by 2. Since, React is running in StrictMode for development, this might be confusing for newbies. Found here: https://react.dev/learn/keeping-components-pure#side-effects-unintended-consequences
Edit: The deep dive for this chapter contains the explanation.
Page
https://react.dev/learn/keeping-components-pure
Details
Add another small example where it shows that we do get types when using inline methods, to make it more clear.
Either turn off Strict mode for this example OR explain why we are getting 2, 4, 6 instead of the expected 1, 2, 3 because of React.StrictMode.
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Abra a página vinculada keeping-components-pure e a seção Using TypeScript e, em seguida, localize a discussão sobre eventos do DOM relacionada à extração de funções. Adicione um pequeno exemplo de método inline mostrando que os tipos de evento são inferidos e confirme que a explicação é clara para quem está começando.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- react, typescript
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 50/100