Skip to content

Instantly share code, notes, and snippets.

@hyber1z0r
Created August 4, 2020 10:03
Show Gist options
  • Save hyber1z0r/9718794116e5ae72aee73c3aaf095fca to your computer and use it in GitHub Desktop.
Save hyber1z0r/9718794116e5ae72aee73c3aaf095fca to your computer and use it in GitHub Desktop.
useTimeout example
import React, { useState } from 'react';
import useTimeout from './useTimeout';
const NewsletterBanner = () => {
// Wait 5 seconds before poppung up banner
const wait = 5000;
const [visible, setVisible] = useState(false);
useTimeout(() => {
setVisible(true);
}, wait);
if (!visible) return null;
return (
<div>
... some newsletter modal
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment