Last active
January 12, 2020 21:03
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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