DEV Community

Discussion on: React custom hook to fetch data

Collapse
 
abhmohan profile image
abhmohan

You can put them in the dependencies array. No problem. That becomes a different scenario meaning every time url or options change, callback is fired. In my case I want the callback to be fired only once. So the dependencies array empty. You can imagine how componentDidMount works in a class component. It gets called only once after the initial rendering.