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

Warning : "defaultProps" will be removed #7287

Closed
khuyenho opened this issue Oct 16, 2023 · 1 comment · Fixed by #7296
Closed

Warning : "defaultProps" will be removed #7287

khuyenho opened this issue Oct 16, 2023 · 1 comment · Fixed by #7296

Comments

@khuyenho
Copy link

khuyenho commented Oct 16, 2023

Describe the problem

React version 18 doesn't use defaultProps anymore. It gave this warning every time I ran the app, and the logs are very long, it kind of annoying.
image

The root of the problem here: https://github.com/elastic/eui/blob/main/src/components/button/button.tsx#L135
Other components might also be affected.

Proposed solution

Before

EuiButton.defaultProps = {
  size: 'm',
  color: 'primary',
};

After

export const EuiButton = ({ size = 'm', color = 'primary' }) => {
  // Your component logic here
  return (
    <EuiButton size={size} color={color}>
      Button
    </EuiButton>
  );
};

You can set default values directly within the component function.

@JasonStoltz
Copy link
Member

Hey team 👋 . I marked this as high priority and sized it as small. Let's see if we can get this cleaned up quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants