reactjs / reactjs/react.dev

[Suggestion]: rename `useImperativeHandle` for clarity

Abierto
#8,469 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

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

Descripción

Summary

[!NOTE]
This is not specific to the docs site but I could not find an appropriate issue to file this under the main repo. Is this the appropriate place to discuss API naming and offer suggestions? If not, please let me know where I should redirect my question!

While the docs page does a good job of explaining how and when useImperativeHandle is used, I think it would be much clearer if the API were renamed to useProxy, useProxiedRef, useReflectedRef, or some other similar name as it makes it clearer that all you are doing is reflecting/proxying a ref that is passed in by consumers.

Page

https://react.dev/reference/react/useImperativeHandle

Details

"imperative" in imperativeHandle is unclear, should it be interpreted as important/necessary or imperative in the programming sense? Either way I don't think it's easy to understand. I've used this hook enough times by now that I am familiar with when/why it's needed but to someone new to React this is probably one of the more obscure hooks. Handle is also unclear as that has other meanings in other programming languages. I think "proxy" is a more universally understood term for "wrap/modify/mock something and pass it along" which is what this hook is doing.

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 con la página referenciada de useImperativeHandle en react.dev/reference/react/useImperativeHandle y revisa si este repositorio de documentación puede abordar un cambio de nomenclatura de la API. El issue solo estará completo después de que se decida la propuesta de nomenclatura o se redirija la discusión al repositorio principal correspondiente.

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
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.