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

332
Views
How can I fix eslint: react/destructuring-assignment error?

const Container = (props) => {
    return (
        <StyledDiv>
            <SmallScreenDiv>{props.children}</SmallScreenDiv>
        </StyledDiv>
    );
};

This is my code and error happens at {props.children}
how can I fix this eslint error?

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

0

You can also destruct your props like this:

const Container = ({children}) => {
    return (
        <StyledDiv>
            <SmallScreenDiv>{children}</SmallScreenDiv>
        </StyledDiv>
    );
};
about 4 years ago · Juan Pablo Isaza Report

0

There are two solution for this

  1. Disable the prefer-destructuring feature on the eslint

  2. destructure your props

     const Container = ({children}) => {
     return (
         <StyledDiv>
             <SmallScreenDiv>{children}</SmallScreenDiv>
         </StyledDiv>
     );
     };
    

or

   const Container = (props) => {
    const {children} = props
    return (
        <StyledDiv>
            <SmallScreenDiv>{children}</SmallScreenDiv>
        </StyledDiv>
    );
    };

I will recommend to use second option.

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!