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

[Bug]: react/destructuring-assignment rule not working inside forwardRef #3631

Open
2 tasks done
kostas-politis opened this issue Sep 9, 2023 · 0 comments
Open
2 tasks done
Labels

Comments

@kostas-politis
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

The rule react/destructuring-assignment won't apply on component passed in forwardRef.

Expected Behavior

import { forwardRef } from "react";

interface Props {
  day: string;
}

// Code to expect error but works just fine
export const MyComponent = forwardRef<HTMLDivElement, Props>(
  function MyComponent(props, ref) {
    return <div ref={ref}>{props.day}</div>;
  }
);

// Correct code 
export const MyComponent = forwardRef<HTMLDivElement, Props>(
  function MyComponent({ day }, ref) {
    return <div ref={ref}>{day}</div>;
  }
);

eslint-plugin-react version

v7.33.2

eslint version

v8.48.0

node version

v18.15.0

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

No branches or pull requests

1 participant