Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Remove default props from functional components #7

Open
marteinn opened this issue Mar 12, 2023 · 0 comments
Open

Enhancement: Remove default props from functional components #7

marteinn opened this issue Mar 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@marteinn
Copy link
Member

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'}) => {
    ...
@marteinn marteinn added the enhancement New feature or request label Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant