Skip to content

Instantly share code, notes, and snippets.

@aibolik
Last active January 12, 2020 21:03
Show Gist options
  • Select an option

  • Save aibolik/76394b51ffa617faf569e0f0cd5b2db5 to your computer and use it in GitHub Desktop.

Select an option

Save aibolik/76394b51ffa617faf569e0f0cd5b2db5 to your computer and use it in GitHub Desktop.
ToastContainer component - part of post - https://aibolik.github.io/blog/creating-toast-api-with-react-hooks
const Wrapper = styled.div`
position: absolute;
/* Top right corner */
right: 0;
top: 0;
`;
const ToastContainer = ({ toasts }) => {
return createPortal(
<Wrapper>
{toasts.map(item => (
<Toast key={item.id} id={item.id}>{toast.content}</Toast>
)}
</Wrapper>,
document.body
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment