Skip to content

Instantly share code, notes, and snippets.

@henev
Last active April 12, 2022 22:30
Show Gist options
  • Save henev/48f7be0f1209129de274f57cafbb1bd2 to your computer and use it in GitHub Desktop.
Save henev/48f7be0f1209129de274f57cafbb1bd2 to your computer and use it in GitHub Desktop.
Toast Component
import React from 'react';
import { useTimeout } from '../hooks/useTimeout';
export const Toast = (props) => {
useTimeout(props.close, 5000);
return (
<div className="toast">
<div className="toast__text">{props.children}</div>
<div>
<button onClick={props.close} className="toast__close-btn">
x
</button>
</div>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment