Incorrect referred documentation in fetching with Hooks
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
The provided documentation is not accurate because it refers to an article that is not correct based on the eslint(react-hooks/exhaustive-deps) rules.
https://reactjs.org/docs/hooks-faq.html#how-can-i-do-data-fetching-with-hooks
Documentation quote:
"How can I do data fetching with Hooks?
Here is a small demo to get you started. To learn more, check out this article about data fetching with Hooks."
Referred Article's URL: https://www.robinwieruch.de/react-hooks-fetch-data
In the provided example we have:
useEffect(async () => {
const result = await axios(
'https://hn.algolia.com/api/v1/search?query=redux',
);
setData(result.data);
}, []);
but the rule from eslint(react-hooks/exhaustive-deps) says:
Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
useEffect(() => {
async function fetchData() {
// You can await here
const response = await MyAPI.getData(someId);
// ...
}
fetchData();
}, [someId]); // Or [] if effect doesn't need props or state
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla pagina delle FAQ di Hooks ed esamina l’articolo collegato sul recupero dei dati, quindi confronta il relativo esempio useEffect con le indicazioni di eslint(react-hooks/exhaustive-deps citate nell’issue. Il lavoro è concluso quando la documentazione non rimanda più i lettori a indicazioni inaccurate e l’esempio di recupero è coerente con la regola indicata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100