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

feat(useExhaustiveDependencies): add option to useExhaustiveDependencies to enable errors when the dependencies array is missing #4149

Conversation

simon-paris
Copy link
Contributor

Continuation of #630. Makes the behaviour disabled here optional.

Summary

Adds an option reportMissingDependenciesArray to catch extra re-renders caused by missing dependency arrays.

// this config
"useExhaustiveDependencies": {
  "reportMissingDependenciesArray": true,
}

// causes this to be an error
function ReportMissingDependenciesArray() {
    const [a] = useState("hello");
    useEffect(() => {
        console.log(a); // <- runs every render
    });
    return <div/>;
}

Also added changelog entry for this and for #630.

Test Plan

A unit test is added

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Oct 1, 2024
Copy link

codspeed-hq bot commented Oct 1, 2024

CodSpeed Performance Report

Merging #4149 will improve performances by 56.35%

Comparing simon-paris:feat/use-exhaustive-dependencies-missing-deps-array-2 (321c153) with main (7e29f06)

Summary

⚡ 1 improvements
✅ 104 untouched benchmarks

Benchmarks breakdown

Benchmark main simon-paris:feat/use-exhaustive-dependencies-missing-deps-array-2 Change
big5-added_15586211152145260264.json[uncached] 857.7 µs 548.6 µs +56.35%

@simon-paris simon-paris changed the title feat: Add option to useExhaustiveDependencies to enable errors when the dependencies array is missing feat: add option to useExhaustiveDependencies to enable errors when the dependencies array is missing Oct 1, 2024
@simon-paris simon-paris changed the title feat: add option to useExhaustiveDependencies to enable errors when the dependencies array is missing feat(useExhaustiveDependencies): add option to useExhaustiveDependencies to enable errors when the dependencies array is missing Oct 1, 2024
Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@arendjr arendjr merged commit 3baa9fc into biomejs:main Oct 1, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants