No video

React JS Interview Questions ( useThrottle Hook ) - Frontend Machine Coding Interview Experience

  Рет қаралды 11,487

RoadsideCoder

RoadsideCoder

Күн бұрын

Пікірлер: 29
@RoadsideCoder
@RoadsideCoder 6 ай бұрын
🔴 Get my Complete Frontend Interview Prep course - roadsidecoder.com/course-details ➡ Book an Interview Preparation call with me ( 20% OFF for limited time ) - topmate.io/roadsidecoder
@mangeshrakhonde4396
@mangeshrakhonde4396 Ай бұрын
I think you have given example of debouncing as window resizing is usecase of debouncing. -Regardless of resizing it will only show output at a certain time means we are delying the function call. -(showing output/exicuting function) only when event pause is usecase of debouncing.
@siddhartsingh6606
@siddhartsingh6606 6 ай бұрын
Why delay - (date now() - lastExecruted) as condition for setTimeout
@dhruvdhar1
@dhruvdhar1 9 күн бұрын
why do you need to keep track of prev executed time, why not do something like this instead? export const useThrottle = (inputVal, delay) => { const [throttledVal, setThrottledVal] = useState(inputVal) const timer = useRef(null) useEffect(() => { if(!timer.current) { setThrottledVal(inputVal) timer.current = setTimeout(() => { timer.current = null }, delay) } }, [inputVal, delay]) return throttledVal }
@rajneeshsaroha1019
@rajneeshsaroha1019 3 ай бұрын
Dude 😐, just put a console.log("expensive api call") inside handleResize function, and look out the logs in console, you will get to know the problem with the code. Its an infinite expensive api calls irrespective of the resizing event. But yeah, great efforts, I think somehow we have to remove the use of useState from our custom hook to resolve the code here.
@Solo_playz
@Solo_playz 6 ай бұрын
But we can also use the intersection observer API to get this infinite scroll effect right? BTW great video ❤
@yuvarajpandiyans1891
@yuvarajpandiyans1891 2 ай бұрын
same feeling
@heena2002
@heena2002 6 ай бұрын
Great tutorial piyush 🙏 Can you also make one on how to build a voting poll in react js.
@MrColins710
@MrColins710 6 ай бұрын
cool lesson! thank you
@akshitagarwal9850
@akshitagarwal9850 Ай бұрын
This code is incorrect. Just add a console.log statement in the handler, and you will see. Not only is it executing the code at every interval even when the window size is not changing, but it also requires the handler to have a new reference to work properly. Please avoid adding misleading videos.
@sankalpsachan9199
@sankalpsachan9199 6 ай бұрын
May be they were using intersection observer as i noticed that as soon as i see the load more button at the very bottom the next api is called!
@Aviralsingh-yw7xx
@Aviralsingh-yw7xx 6 ай бұрын
Sir pleasedo a todo app with CRUD operations machine coding question.
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 6 ай бұрын
Superb
@bloggerayush8550
@bloggerayush8550 5 ай бұрын
Bro, please explain as well...in the last you are directly writing the code ..for a new person it is difficult
@RoadsideCoder
@RoadsideCoder 5 ай бұрын
Noted
@bloggerayush8550
@bloggerayush8550 5 ай бұрын
thanks bhai, please do not take it in a negative way bhai. Bss mujhe lga.....@@RoadsideCoder
@user-dd7kw3ym5i
@user-dd7kw3ym5i 6 ай бұрын
why not use debouncing instead ?
@RoadsideCoder
@RoadsideCoder 6 ай бұрын
They are both separate techniques
@jacquelynecarmen
@jacquelynecarmen 6 ай бұрын
@kaushalkumar6666
@kaushalkumar6666 6 ай бұрын
why not use Intersection Observer API ?
@RoadsideCoder
@RoadsideCoder 6 ай бұрын
I will bring that too
@shubhankar-13
@shubhankar-13 6 ай бұрын
Great
@yashsolanki069
@yashsolanki069 6 ай бұрын
What if we use debounce lodash func. For this purpose?
@rakib_bhai74
@rakib_bhai74 6 ай бұрын
Will call the api for every event after first event out from call stack till last event
@yashsolanki069
@yashsolanki069 6 ай бұрын
@@rakib_bhai74 with debounce understanding is that it will only execute the function once the activity is finished i.e. resize within the given delay time. So isn't debouncebetter here. Because with the throttle approach it will be called after time delay constantly right? Here, the reason to choose for debounce because the api call has fetching data and formatting data and then updating UI so due to complex operation i believe debounce would be better.
@rishiraj2548
@rishiraj2548 6 ай бұрын
👍👍
@Harsh-fv2kg
@Harsh-fv2kg 5 ай бұрын
Can any one please explain the code at 15:45? I just passed simple delay as an args instead of delay - (Date.now() - lastExecuted.current). It works fine. Couldn't find any error. What's the point of writing that line? Many thanks in advance.
@skabadathaque8046
@skabadathaque8046 6 ай бұрын
Denounced hook
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 406 М.
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 12 МЛН
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 48 МЛН
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 103 МЛН
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 472 М.
How I Write Clean Code in React
16:36
Cosden Solutions
Рет қаралды 28 М.
React Interview Questions | Beginner to Advanced
26:42
PedroTech
Рет қаралды 27 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 12 МЛН