Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Reemplace el node de texto con React Element a través de react-native-render-html en React Native

Problema

Estoy usando react-native-render-html para renderizar algo de html en React Native . El problema es que este html contiene algunos marcadores de posición como {{{placeholder:items:0}}} que deben reemplazarse con un React Element .

Código

Estoy usando la función onText actualmente como se describe en este ejemplo :

 function onText(text) {
 const toReplace = text.data.match(gemstoneRegex);

 if (toReplace?.length) {
 let [placeholder] = toReplace;
 placeholder = placeholder.replace(/\{/g, "");
 placeholder = placeholder.replace(/\}/g, "");

 const [name, position] = placeholder.split(":items:");

 text.data =
 (
 <Gemstone
 stones={[gemstones[name]?.de[position]]}
 displayTitle={gemstones[name]?.de[0]?.displaytitle || name}
 fieldName={name}
 />
 ) || `${name} couldn't be replaced!`;
 }
 }

Esto funcionaría bien para una cadena de texto simple, pero desafortunadamente no para un elemento React . ¿Hay alguna forma de hacer esto? La función onElement parece tener métodos de utilidad para agregar y eliminar elementos. ¿Es eso también posible para los nodejs de texto?

almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!