frontend-interview-questions icon indicating copy to clipboard operation
frontend-interview-questions copied to clipboard

custom-useEffect hook does not function like useEffect.

Open kobbin003 opened this issue 1 year ago • 1 comments
trafficstars

In useEffect, when there is an update of state, the cleanup function of old state runs and then the callback function of the updated state runs. In your code, when there is an update of state, the callback function of the updated state runs and then the cleanup function of updated state runs. The cleanup runs same as callback.

kobbin003 avatar Aug 21 '24 13:08 kobbin003

@kobbin003 Were you able to solve this ?

AmanKhan9 avatar Jun 18 '25 18:06 AmanKhan9