Skip to content

Instantly share code, notes, and snippets.

@myogeshchavan97
Last active April 4, 2021 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myogeshchavan97/0080f90fc420f90bec13e7e44d22640f to your computer and use it in GitHub Desktop.
Save myogeshchavan97/0080f90fc420f90bec13e7e44d22640f to your computer and use it in GitHub Desktop.
useEffect Demo
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
const App = () => {
const [counter, setCounter] = useState(0);
useEffect(() => {
console.log("useEffect called");
});
return (
<div>
<p>Counter is {counter}</p>
<button onClick={() => setCounter(counter + 1)}>Increment</button>
</div>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment