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

82
Views
react parent components passing child a prop with different name

Sorry for the terrible question name, I'm wondering if there is a standard way of passing a different value for the same prop from different parents and if there's something wrong with the way I am spreading my props.

Parent 1:

<ChildComponent
prop1={prop1}
prop2={prop2}
paymentProcessingDate={Date.now()}
...passThroughProps
>

Parent 2 which has a prop carServiceDate

<ChildComponent
prop1={prop1}
prop2={prop2}
paymentProcessingDate={carServiceAppointment.date}
...passThroughProps
>

Both Parent1 and Parent2 make use of ChildComponent but need to pass in a different value for paymentProcessingDate. I'm receiving an error that the spread of passThroughProps will always overwrite paymentProcessingDate but the first time paymentProcessingDate is used or defined is in the call to ChildComponent. Any help or suggestions is really appreciated!!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The ...passThroughProps must contain a value for paymentProcessingDate so TypeScript is complaining that your spread prop will overwrite whatever you explicitly set.

Try moving the spread to the top and see if that fixes it:

<ChildComponent
...passThroughProps
prop1={prop1}
prop2={prop2}
paymentProcessingDate={carServiceAppointment.date}
>

Or if possible, remove paymentProcessingDate from passThroughProps.

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!