react-testing-library icon indicating copy to clipboard operation
react-testing-library copied to clipboard

refac: Add a dependency array for useEffect

Open ssi02014 opened this issue 2 years ago • 2 comments

What:

I added a dependency array for useEffect.

What: It would be clearer to add a dependency array, and some code already has one.

Checklist:

  • [x] Documentation added to the docs site
  • [x] Tests
  • [x] TypeScript definitions updated
  • [x] Ready to be merged

ssi02014 avatar Oct 10 '23 08:10 ssi02014

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d1ff5d6fa7762107a9f8a4fc9a0dc3da07cc92dd:

Sandbox Source
React Configuration
react-testing-library-examples Configuration

codesandbox-ci[bot] avatar Oct 10 '23 08:10 codesandbox-ci[bot]

Codecov Report

Merging #1243 (d1ff5d6) into main (d80319f) will not change coverage. The diff coverage is n/a.

@@            Coverage Diff            @@
##              main     #1243   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          192       192           
  Branches        40        40           
=========================================
  Hits           192       192           
Flag Coverage Δ
canary 100.00% <ø> (ø)
experimental 100.00% <ø> (ø)
latest 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/pure.js 100.00% <ø> (ø)

:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

codecov[bot] avatar Oct 10 '23 08:10 codecov[bot]

Having an empty dependency array in useEffect does not have the same behavior as not having a dependency array, one will run only on mount and the second will run on every re-render. I'm not sure this change is needed here. Thanks for putting the time and effort into this, but I'm closing this PR :)

MatanBobi avatar Apr 24 '24 08:04 MatanBobi