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

1.8K
Views
propType [name] is not required, but has no corresponding defaultProps declaration ReactJS
      import styled from 'styled-components'
      import propTypes from 'prop-types'
      import React from 'react'
  const Checkbox = ({ className, checked, ...props }) => (
  <CheckboxContainer className={className}>
    <HiddenCheckbox checked={checked} {...props} />
    <StyledCheckbox checked={checked}>
      <Icon viewBox="0 0 24 24">
        <polyline points="20 6 9 17 4 12" />
      </Icon>
    </StyledCheckbox>
  </CheckboxContainer>
)

Checkbox.propTypes = {
  checked: propTypes.boolean,
  className: propTypes.string,
}

I have this component and I'm always getting this error : error propType "className" is not required, but has no corresponding defaultProps declaration react/require-default-props

I don't know how to fix it any suggestions please?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's explained in the documentation: https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values

As you are marking this prop as not required it is asking you to put a default in case the prop is missing.

So, something like this (but default values depends on you):

Checkbox.defaultProps = {
  checked: false,
  className: null,
}
over 4 years ago · Santiago Trujillo 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!