Skip to content

Instantly share code, notes, and snippets.

@seanrankin
Created February 7, 2019 14:41
Show Gist options
  • Save seanrankin/ca419acdef4161580ef35320ecd3f517 to your computer and use it in GitHub Desktop.
Save seanrankin/ca419acdef4161580ef35320ecd3f517 to your computer and use it in GitHub Desktop.
import React, { useEffect, useState } from 'react';
export const EffectHook = () => {
const [count, setCount] = useState(0);
useEffect(() => {
document.title = `You clicked ${count} times`;
console.log(`useEffect ${count}`);
});
return <button onClick={() => setCount(count + 1)}>Effect Hook {count}</button>;
};
export const StateHook = () => {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>State Hook {count}</button>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment