Eslint-plugin-react: [require-default-props] Don't support default values with js destructuring

Created on 1 Jul 2019  路  3Comments  路  Source: yannickcr/eslint-plugin-react

You can see the problem next:

// @flow
import React from 'react';

type Props = {
  title: string,
  text?: string, // eslint error 'react/require-default-props'
};

export const TestComp1 = ({ title, text = '' }: Props) => (
  <button title={title}>{text}</button>
);

All 3 comments

Use defaultProps, not default values.

what if i don't wanna?
that should be an option

That's always an option - disable the rule.

Was this page helpful?
0 / 5 - 0 ratings