Couldn't use match index (replace function second arg) as a key
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react
- Área
- frontend
Línea de trabajo
Empieza leyendo la API de reactStringReplace y el comportamiento del callback replacer descritos en este issue, incluido cómo se usa actualmente el parámetro offset. Decide si un índice acumulativo o un argumento adicional del callback conserva los workflows existentes; después documenta la decisión y verifica que las sustituciones repetidas produzcan React keys únicos sin consumir coincidencias.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hello! First of all, thanks for the nicest replacer for react. )))
There's a thing. I want to use index parameter in replacer function as a key for react to be happy and render all my replaced texts. If I do two replaces at a time, say
const firstStepTexts = reactStringReplace(myText, regex1, (match, i) => <span key={`first_${i}`}>{match}</span>)
const second = reactStringReplace(firstStepTexts, regex2, (match, i) => <span key={`second_${i}`}>{match}</span>)
Then, for initial string in pattern of ${match_second_regex_1} ${match_first_regex} ${match_second_regex_2} replacer would set the same key for both second regex matches, and then react would blow up swallowing the second match span entirely.
What I did for now was embedding offset param from the new lib version, but that's not the real solution obviously.
What I could do right now is to call .reduce with running total index and not calling reactStringReplace on array, but that way I'm missing perfect lib api use-case. From the api point of lib, I could think of two possible things: 1) having second argument for replace function be running index, and not exact string match index; or 2) having another one argument with that index for replacer function.
First option would almost definitely break someone's workflow (https://xkcd.com/1172/), second one makes api clunky (arghhh, fourth parameter).
What's your opinion on this? I would be happy to help with code, but messing with api without your decision feels not a way to go.
- Lenguaje dominante
- JavaScript
- Estrellas
- 666
- Forks
- 54
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de iansinnott/react-string-replace
-
not a replacement functionAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
iansinnott/react-string-replace#89 · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 38/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
iansinnott/react-string-replace#64 · 2 comentarios · 2 reacciones ·
Todos los issues de iansinnott/react-string-replace
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Design only Leadership Survey SLFS
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
bcgov/digital-journeys#2293 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
tursodatabase/turso#9405 ·
Los mantenedores suelen responder en 1 día
-
Toolkit
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
API Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ProjectSidewalk/SidewalkWebpage#5556 ·
Los mantenedores suelen responder en 1 día