Skip to content

Instantly share code, notes, and snippets.

@smgrv123
Created February 11, 2022 09:11
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 smgrv123/ca8ac47c8cefed07239d772082852464 to your computer and use it in GitHub Desktop.
Save smgrv123/ca8ac47c8cefed07239d772082852464 to your computer and use it in GitHub Desktop.
import React from 'react'
import { useState, useEffect } from 'react';
const useDocumentTitle = (title) => {
useEffect(() => {
console.log(title)
}, [title])
}
export default App = () => {
const [count, setCount] = useState(0);
const incrementCount = () => setCount(count + 1);
useDocumentTitle(count)
return (
<div>
<p>You clicked {count} times</p>
<button onClick={incrementCount}>ClickMe</button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment