Web / ReactJS Interview questions
How would delay an API call until the component has mounted?
In a class component, make the API call from componentDidMount() life cycle method.
In a functional component, use useEffect hook to make the API call with the second argument as an empty array. When it's an empty list/array, the callback will only be fired once, similar to componentDidMount.
More Related questions...