Quick Setup
git clone https://github.com/shaunak24/youtube-clone.git
cd youtube-clone
npm install
npm start
Tips for Machine Coding Round -
Clarify the requirements. Never start coding directly (5 min)
Planning (5 min)
What is debouncing?
Building Live Chat
Additional hooks (useMemo, useCallback, useRef)
useMemo is a React Hook that lets you cache the result of a calculation between re-renders
To avoid heavy operations for every (unrelated) re-render, we place it inside useMemo
Ex. const cachedValue = useMemo(calculateValue, dependencies);
useCallback is a React Hook that lets you cache a function definition between re-renders
Ex. const cachedFn = useCallback(fn, dependencies);
useRef is a React Hook that lets you reference a value that’s not needed for rendering
It is persisted between re-renders
Ex. const ref = useRef(initialValue);