Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adding second hook
import React, { useState, useEffect } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
useEffect(() => {
// Update the document title using the browser API
document.title = `You have written ${count} hooks`;
return (
<p>You have written {count} hooks</p>
<button onClick={() => setCount(count + 1)}>
Click me
export default Example;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.