Skip to content

Commit

Permalink
Disable require-default-props lint rule
Browse files Browse the repository at this point in the history
The require-default-props lint rule was being overly restrictive for
this use case. There is no good reason to include a value in
`defaultProps` if it is truly optional, as that just means that React
now has to do the work to merge this `undefined` value into props for no
reason.

I'd argue that you should just avoid `defaultProps` all together and use
destructuring with default values, but that's maybe more personal
preference.
  • Loading branch information
Brandon Dail committed Dec 13, 2019
1 parent 6ff4922 commit 247e45e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Expand Up @@ -17,6 +17,7 @@ env:
rules:
react/jsx-filename-extension: 0
react/jsx-props-no-spreading: 0
react/require-default-props: 0
no-duplicate-imports: 2 # doesn't support flow imports.
no-console: 0
func-style: 2
Expand Down
2 changes: 1 addition & 1 deletion src/components/Elements.js
@@ -1,5 +1,5 @@
// @flow
/* eslint-disable react/forbid-prop-types, react/require-default-props */
/* eslint-disable react/forbid-prop-types */
import React, {useContext, useMemo, useState} from 'react';
import PropTypes from 'prop-types';

Expand Down
2 changes: 0 additions & 2 deletions src/components/createElementComponent.js
Expand Up @@ -134,8 +134,6 @@ const createElementComponent = (type: string) => {
};

Element.defaultProps = {
id: undefined,
className: undefined,
onChange: noop,
onBlur: noop,
onFocus: noop,
Expand Down

0 comments on commit 247e45e

Please sign in to comment.