Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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