🚀🚀 Hello Everyone,
In this video, we have discussed the timing & state issues with the setTimeout browser API. Such problems are generally asked in the React Coding/ Machine Coding round at the Frontend interview.
Problem Statement: Write the useTimeout hook that should take two parameters, the same as setTimeout which are the callback function and the delay, and execute the given callback after the exact delay. The callback should be able to access the latest component state.
We have discussed the following aspects:
1. Issues with the setTimeout and React State
2. Approach to the solution
3. Refactor the solution/create the re-useable hook
Let's Connect:
Github: https://github.com/mkdudeja
Topmate: https://topmate.io/mkdudeja
Twitter: / mkdudeja
LinkedIn: / mkdudeja
Facebook: / mkdudeja
Instagram: / mkdudeja
Thanks,
Manish K. Dudeja
#javascript #reactjs #frontendinterview #interviewquestion