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
How to inherit and overide object in JS

I have a react StyleSheet with objects

  const styleSheet = StyleSheet.create({
    picture1: {
      height: 50,
      width: 30,
      alighItems: 'center',
    }
    picture2: {
      height: 50,
      width: 50:,
      alighItems: 'center',
    }
  })

My question is : How do I assign properties of picture1 to picture2, and ovveride width to 50?

So I could write just picture2: {width: 50} without having to rewrite same code?

I tried this way but unfortunately it didn't work.

 const styleSheet = StyleSheet.create({
    picture1: {
      height: 50,
      width: 30,
      alighItems: 'center',
    }
    picture2: {
      ...picture1,
      width: 50:,
    }
  })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  const picture1 = {
    height: 50,
    width: 30,
    alignItems: 'center', // Note: alignItems not alighItems!
  }
  const styleSheet = StyleSheet.create({
    picture1,
    picture2: {
      ...picture1,
      width: 50,
    }
  })
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!