`defaultProps` rule to be deprecated on function components
See original GitHub issuedefaultProps
on function components is getting deprecated by React (see: https://github.com/facebook/react/pull/16210)
For this rule to follow suit, it should only be triggered when missing from class components.
The official recommendation in future versions of React is to use ES6 default values for function components.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:32
- Comments:27 (13 by maintainers)
Top Results From Across the Web
`defaultProps` rule to be deprecated on function components
defaultProps on function components is getting deprecated by React (see: facebook/react#16210) For this rule to follow suit, it should only ...
Read more >Stop using defaultProps - Notes and Anecdotes
And because Dan says defaultProps will be deprecated from React, which is the only reason we use them to begin with. Performance. By...
Read more >React functional component default props vs ...
defaultProps on functional components will eventually be deprecated (as per Dan Abramov, one of the core team), so for future-proofing it's ...
Read more >An alternative to default props for React functional components
I read recently that default props for functional components will one day be deprecated in React. It's currently possible (as of September ...
Read more >"@hswolff @reactjs Because defaultProps on functions will ...
Because defaultProps on functions will eventually get deprecated. 11:30 PM · May 29, 2019.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The change isn’t to remove
defaultProps
from function components, but to use the official ES6 standard for defaulting props using object deconstruction and default assignment.Where we once had:
We now have:
The goal isn’t to remove
defaultProps
, but change how they’re defined on function components.I would expect the
defaultProps
rules to function the same regardless of if I usedefaultProps
or object deconstruction and default assignment.Yes, it means someone would have to do the development work to add an option.
It makes sense to me to modify
require-default-props
so that the default is “defaultProps” for everything, but that there’s an option for function components to instead require “default arguments”, or, to ignore function components.