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

180
Views
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 answers
Answer question

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 Report
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!