I'm attempting to show a Chakra-UI Toast programmatically using the Chakra-UI React.js component library and am struggling to get it to work. The Chakra-UI Toast documentation only shows how to show the toast based on a button click, but I'd like to display it programmatically - in a returned promise after an AJAX call is made. I'm not sure if it's feasible, but I'd like to have a showToast function I could call to show it.
I'm in the process of integrating Chakra-UI into a React.js web application and am fairly new to both React.js and Chakra-UI.
Update
Here is a CodeSandbox showing what I am trying to achieve: https://codesandbox.io/embed/upbeat-rhodes-9zkii. I have a button in there that shows the toast when it's clicked, but I'd like to show it in the setTimeout where the TODO is located.