question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading toast status

See original GitHub issue

🚀 Feature request

A new toast status called loading, and this one should display a spinner icon.

🧱 Problem Statement / Justification

Some toast libraries have a loading toast state, and it gives a great feedback for the user and the developer doesn’t need to put the spinners directly in the screen and implementing loading conditions and this type of thing.

✅ Proposed solution or API

Shoud exist a new toast status:

const toast = useToast()

toast({
  title: "Loading...",
  status: "loading", // | "info" | "warning" | "success" | "error"
  isClosable: false,
})

So, based on that property, the toast should display the spinner and a default background color, that can be light blue or other one that fits better.

↩️ Alternatives

Maybe if there’s a way to attach the toast to a state, commonly const [loading, setLoading] = useState(false), and then the toast would appear/disappear depending on the state. In the current implementation, only the duration is defined, and if this “trigger” based in a variable can be implemented I think would fit better, especially for this loading toast.

📝 Additional Information

It would be similar to this: image from Cogo Toast

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mattwells19commented, May 8, 2021

This is a really interesting idea. You can sort of replicate this by storing the id of the generated toast and then use that id to close the toast when the promise gets resolved.

I was intrigued so I made a codesandbox to show what I mean: https://codesandbox.io/s/chakra-async-toasts-pbm9x.

Unfortunately I had to manually recreate the styles for the toast since the Chakra toast component isn’t exported on its own. I guess that’s more of a reason to bake this kind of solution into Chakra instead of having it bolted on like this.

Would love to get thoughts from others as I like the idea of this sort of async toast.

2reactions
jatin33commented, Jun 27, 2021

@with-heart i would like to give this a shot, please assign this to me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is Toast Down? Check Toast status and current outages
Check if Toast is down. Monitor Toast status changes, problems, outages, and user reports. Get instant notifications.
Read more >
React Loading State Pattern using Toast & SWR
Easily manage react loading state with React Hot Toast and SWR ... The toast will show status when loading, and when it is...
Read more >
toast() API
Creates a custom notification with JSX without default styles. Loading. toast.loading('Waiting...') ...
Read more >
Troubleshooting Toast App Updates
1. Login into your device with your email and password. 2. Open the Settings app and select Apps on your device. 2. Find...
Read more >
Toast Overlay - Components
A toast overlay is used to provide system status notifications, such as error, completion, and loading progress messages. The icon toast and text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found