Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
typescript string interpolation with lodash

In my application, I have a H custom component that takes in a header and a subheader as props.

For my header prop, I want to concatenate the lodash expression with a string. See below my code.

        <H
          header= `${_.startCase(type)} SomeString`
          subheader= "Lorem ipsum do eiusmod"
        />

I have tried the suggestions here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals, but maybe because I am using lodash it is not working.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The syntax for your prop is incorrect:

header={`${_.startCase(type)} SomeString`}

In React, any prop value that contains code must be enclosed in {}.

Only constant strings like prop="a string" may be passed without a pair of enclosing {}. All other values require it*.


* Well, there are two special cases.

children which is set like the following. Here children is something like <>content</>.

<MyComponent>content</MyComponent>

And boolean shorthand props. Here isCool is true.

<MyComponent isCool />

Although, if you want to set it to false you need curly braces again:

<MyComponent isCool={false} />
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda