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

298
Views
How to declare prop default in Storybook without using defaultProps?

I am not using React's .defaultProps system and instead relying on spreading my default props into my provided props:

type PropTypes = {
  /** My property desc */
  someProp?: boolean
}

const defaultProps = {
  someProp: true
}

const MyComponent = (incomingProps: PropTypes) => {
  const props = {
    ...defaultProps,
    ...incomingProps
  }

  return props.someProp ? <div /> : <span />
}

I am using Flow.js to declare my types and it looks great:

enter image description here

However the default value is not extracted properly because the plugin has no clue about my default props.

How can I declare the default values for props?

I tried:

type PropTypes = {
  /**
   * Some description.
   * @default true
   */
  someProp?: boolean
}

I looked into how TypeScript does it and it also doesn't seem to work. Every addon expects you to use .defaultProps.

about 4 years ago · Juan Pablo Isaza
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!