Chakra-ui: make it possible to use toast outside react context

Created on 13 May 2020  路  1Comment  路  Source: chakra-ui/chakra-ui

Is your feature request related to a problem? Please describe.
Yes, I would like to hook error handling of apollo-client to display a toast

Describe the solution you'd like
ideally I could import something like

import {showToast} from "@chakra-ui/core"

showToast({
      title: "There was an error:",
      description: err.message,
      duration: 7000,
      status: 'error'
})

Describe alternatives you've considered
I could use a toast library like for example https://github.com/CodeSeven/toastr
but I can't theme it with chakra theme and it looks totally different.

Additional context
It might be that the toast will need a portal to the DOM, where there is chakra theme context.
If that's the case, I am fine with putting that into my app. As long as I can then call the globalToast from anywhere outside react.

Feature 馃殌

Most helpful comment

Hi @capaj,

We've added support for this in preparation for v1.

Thanks for your suggestion!

>All comments

Hi @capaj,

We've added support for this in preparation for v1.

Thanks for your suggestion!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

feross picture feross  路  3Comments

woodworker picture woodworker  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

Aneureka picture Aneureka  路  3Comments

polRk picture polRk  路  3Comments