reactjs / reactjs/react.dev

Documentation error in the Render Props - Needs Interpolation

Abierto
#5,049 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
JavaScript
Estrellas
11.8k
Forks
7.9k
Merge medio
1 d 11 h
PR fusionados (30 d)
11

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en la sección Render Props de la documentación de React e inspecciona el ejemplo Cat que muestra las coordenadas del ratón en el estilo de la imagen. Verifica el formato de las coordenadas comparándolo con la documentación circundante y el comportamiento de React; después, actualiza el ejemplo para que el posicionamiento documentado sea correcto y coherente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, react
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.