{"repo":"kentcdodds/stop-runaway-react-effects","free":true,"listed":false,"github":"https://github.com/kentcdodds/stop-runaway-react-effects","clone":"git clone https://github.com/kentcdodds/stop-runaway-react-effects.git","description":"🏃 Catches situations when a react use(Layout)Effect runs repeatedly in rapid succession","language":"JavaScript","stars":794,"topics":["react","hooks"],"license":"MIT","category":"ui-components","readme_excerpt":"stop-runaway-react-effects 🏃 Catches situations when a react use(Layout)Effect runs repeatedly in rapid succession [![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] [![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] The problem React's useEffect and useLayoutEffect hooks accept a \"dependencies array\" argument which indicates to React that you want the callback to be called when those values change between renders. This prevents a LOT of bugs, but it presents a new problem. If your use(Layout)Effect hook sets state (which it very often does), this will trigger a re-render which could potentially cause the effect to be run again, which can lead to an infinite loop. The end result here is that the effect callback is called repeatedly and that can cause lots of issues depending on what that effect callback does (for example, you could get rate-limited by an API you're hitting). Yes, I'm aware that it's unfortunate that we have this problem at all with React. No, I don't think that hooks are worse than classes because of this. No, I'm afraid that this probably can't/shouldn't be built-into React because sometimes your effect just runs a lot and that's intentional. But most of the time it's not intentional so this tool is here to help you know when it's happening so you can fix it. This solution This is a devel","default_branch":null,"files":null,"tree":[],"storefront":"/r/kentcdodds","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/kentcdodds/stop-runaway-react-effects/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}