Skip to content

Instantly share code, notes, and snippets.

@ravewebdev
Last active October 11, 2020 07:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravewebdev/79f363b68918de7d498a0f4385312e52 to your computer and use it in GitHub Desktop.
Save ravewebdev/79f363b68918de7d498a0f4385312e52 to your computer and use it in GitHub Desktop.
4.1. Handle Component State
const FrontendTracker = ( props ) => {
// Add the following before the `return()` block from Part 1, step 2.1.
const [ isLoading, setLoading ] = useState( false );
const [ notice, setNotice ] = useState( null );
useEffect( () => {
if ( null === notice ) {
return;
}
const timer = setTimeout( () => {
setNotice( null );
}, 60000 );
return () => clearTimeout( timer );
}, [ notice ] );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment