Skip to content

Enhancement: Remove default props from functional components #7

@marteinn

Description

@marteinn

According to facebook/react#16210 defaultProps on functional components are deprecated and will be removed in a feature version of React. defaultProps should instead replaced with default values on arguments.

Quick example:

Functional component with defaultProps should go from this:

const Accordion = ({title, text, open, id}) => {
    ...
    
Accordion.defaultProps = {
    title: '',
    text: '',
    open: false,
    id: 'accordion',
};

to this:

const Accordion = ({title = '', text = '', open = false, id = 'accordion'}) => {
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions