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

fix(linter/react_perf): allow new objects, array, fns, etc in top scope #4395

Commits on Jul 23, 2024

  1. fix(linter/react_perf): allow new objects, array, fns, etc in top sco…

    …pe (#4395)
    
    Consider the following code:
    ```tsx
    import { FC } from 'react'
    import { SvgIcon } from '@mui/material'
    
    const StyledIcon = <SvgIcon sx={{ padding: 1, color: '#ff0000' }} />
    //          reported violation  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    export const MyComponent: FC = () => {
        return (
            <div>
                {StyledIcon}
                {/* ... */}
            </div>
        )
    }
    ```
    
    This should not be a violation since the JSX is pre-computed and re-used, which
    does not break React's `Object.is()` checks.
    DonIsaac committed Jul 23, 2024
    Configuration menu
    Copy the full SHA
    ac08de8 View commit details
    Browse the repository at this point in the history