Documentation error in the Render Props - Needs Interpolation
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
Hi Team,
I am trying to give a small correction in the documentation code of React under the topic Render Props.
This isn't such a big issue, but will definitely help newbies and must be addressed.
Under the Render Props concept in React documentation, in one of the examples, where a class component of Cat is created which returns an image, which is positioned absolutely. The position of that image is received through render props.
The received position coordinates are passed to the absolute positioned image. Now the problem is instead of using interpolation and adding units into it, the position coordinates values are directly given in the style object. Surprisingly the Img still moves respectively to the mouse pointer.
But I don't think giving the values without units is the right thing.
So, the below code should be changed from
From:
render() {
const mouse = this.props.mouse;
return (
<img src="/cat.jpg" style={{ position: 'absolute', left: mouse.x, top: mouse.y }} />
);
}
To:
render(){
const mouse = this.props.mouse;
return (
<img src= './imgs/cat.jpg' style={{ left: ${mouse.x}px, top: ${mouse.y}px}} />
)
}
If my understanding is wrong, please correct me.
Much thanks!
Regards,
Hari prasad
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 sezione Render Props della documentazione di React e ispeziona l’esempio Cat che mostra le coordinate del mouse nello stile dell’immagine. Verifica la formattazione delle coordinate rispetto alla documentazione circostante e al comportamento di React, quindi aggiorna l’esempio in modo che il posizionamento documentato sia corretto e coerente.
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
- 48/100