geist-ui icon indicating copy to clipboard operation
geist-ui copied to clipboard

setToast: Toast is never displayed

Open Throvn opened this issue 2 years ago • 8 comments
trafficstars

Bug report 🐞

Version & Environment

  • Version of browser: Firefox 109 but also tested in Chrome, Mac
  • Version of geist-ui/core: ^2.3.8

Expected Behaviour

The behavior I expect is that when I execute the following snippet, a toast will show up somewhere on the webpage:

import './App.css';
import { Button, useToasts } from '@geist-ui/core';

function App() {
  const { setToast } = useToasts()

  return (
    <Button onClick={() => setToast({ text: "Hello" })}>
      Hello</Button>
  );
}
export default App;

Actual results (or Errors)

Nothing is happening at all. When I check the inspector, the DOM is never modified. No errors are thrown either. I tried to produce a minimal reproducable example. For me Toasts do not get displayed at all. Not even in a fresh cra project.

Throvn avatar Feb 01 '23 21:02 Throvn

I also encountered this problem, in nextjs.

dogdogbrother avatar Feb 03 '23 06:02 dogdogbrother

After further investigation, I noticed that the updateToasts() inside of use-toasts.tsx does not call the callback when using the bundled esm npm version.

Throvn avatar Feb 03 '23 22:02 Throvn

After migrating to Next.js, toasts are working flawlessly! (For me, at least) So this has to be some underlying issue, unfortunately I could not figure out how to solve it for client side react.

@dogdogbrother did you set up a new next.js project or did you migrate a CRA project?

Throvn avatar Feb 16 '23 20:02 Throvn

having the same issue here. toasts won't show up in nextjs

rayli09 avatar Feb 26 '23 21:02 rayli09

I have a new nextjs project, and the toasts are not showing up

rayli09 avatar Feb 26 '23 21:02 rayli09

@Throvn could you provide any hints on how to resolve it?

rayli09 avatar Feb 26 '23 21:02 rayli09

After I migrated from my CRA project, Toasts suddenly started to work. When I dug into the code I couldn't PinPoint the bug to something specific. However, if you are working on an open source project I could take a look at your code/config and try to spot potential differences.

Honestly, I think the bug is introduced in a compilation step, but this is just a gut feeling. Are you using typescript?

Throvn avatar Feb 26 '23 21:02 Throvn

I still have this problem in Next.js 13

Sid110307 avatar Mar 22 '24 11:03 Sid110307