Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 974 Bytes

destructuring-props-argument.md

File metadata and controls

45 lines (32 loc) · 974 Bytes

Enforces consistent usage of destructuring props argument assignment(react/destructuring-props-argument)

Rule enforces consistent usage of destructuring assignment in component arguments.

Rule can be set to either of always, never, ignore for each type of the component. Currently only SFC is implemented.

"react/destructuring-props-argument": [<enabled>, { "SFC": "always"}]

Rule Details

By default rule is set to always enforce destructuring assignment. The following pattern is considered warning:

const MyComponent = (props) => {
  return (<div id={props.id} />)
};

Below pattern is correct:

const MyComponent = ({id}) => {
  return (<div id={id} />)
};

If rule option is set to never, the following pattern is considered warning:

const MyComponent = ({id}) => {
  return (<div id={id} />)
};

and below pattern is correct:

const MyComponent = (props) => {
  return (<div id={props.id} />)
};