I have a Gatsby JS based website and I am trying to achieve the loading of a modal/popup after 3 seconds after the index page has loaded.
Here is my code so far:
index.js
const HomePage = ({ data }) => {
const { t } = useTranslation();
useEffect(() => {
setTimeout(() => <Modal
component={<FormA />}
/>, 3000);
}, []);
return (
<Layout>
...
</Layout>
)
}
modal.js
const Modal = (props) => {
return (
<div className='modal'>
<div className="modal-background"></div>
<div className="modal-content">{props.component}</div>
</div>
)
}
export default Modal
No error is detected, but the modal does not show up.
Any clue? Thank you.