hard20 pts · first answer countsreact-hooksdebugging
Effect that fetches forever
This component sends requests in an endless loop. Why?
function Results({ page }) {
const [data, setData] = useState([])
const options = { page, size: 20 }
useEffect(() => {
fetchResults(options).then(setData)
}, [options])
return <List items={data} />
}Discussion 0
Join free to post in the discussion.
Related questions
- Inspecting an API responseFrontend Developer
- Stale value in useEffectFrontend Developer
- position: sticky does not stickFrontend Developer
- Ref value not shown on screenFrontend Developer
- Resize handler that runs many timesFrontend Developer
- Syncing derived values with an effectFrontend Developer
- Race condition in data fetchingFrontend Developer
- Ellipsis that never truncates in FlexboxFrontend Developer