logo
React Hooks - Interview Questions and Answers
How do we fetch data with useEffect?
we can fetch data with useEffect in React by performing the data fetching operation inside the effect function. Typically, we use asynchronous functions like fetch to make HTTP requests to an API endpoint and update the component state with the fetched data.

import React,
{
    useEffect,
    useState
}
    from 'react';

function App() {
    const [count, setCount] = useState(0);

    useEffect(() => {
        console.log("See the Effect here");
    });

    return (
        <div>
            <p>Count: {count}</p>
            <button onClick={() =>
                setCount(count + 1)}>
                Increment
            </button>
        </div>
    );
}
export default App;?