Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: newestOnTop prop is not working on production build #1140

Closed
socker210 opened this issue Jul 21, 2024 · 7 comments
Closed

[BUG]: newestOnTop prop is not working on production build #1140

socker210 opened this issue Jul 21, 2024 · 7 comments
Labels

Comments

@socker210
Copy link

socker210 commented Jul 21, 2024

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Toast stacked like newestOnTop={false} on production build

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

  1. Set newestOnTop={true} to ToastContainer
  2. Run build command with Vite
  3. Run preview command
  4. Then you can see newestOnTop prop is not working as expected

What is the expected behavior?
Toast will stack like newestOnTop={true} on production build

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

  • React: ^18.3.1
  • Browser: Chrome(126.0.6478.183)
  • OS: MacOS(14.4)
  • React-Toastify: ^10.0.5
@mylesadawson
Copy link

I'm also running into this exact same issue. It appears like newestOnTop works on localhost but not after a build:

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

React: ^18.2.0
Chrome: 126.0
MacOS: 14.3
Vite: 5.1.4 (using esbuild)
React-Toastify: ^10.0.5

@VariabileAleatoria
Copy link

any update on this issue?

@socker210
Copy link
Author

any update on this issue?

No updates since I issued 🥲

@cpfnickhoward
Copy link
Contributor

Any thoughts about what the fix might be? Seems like it would have to be this line in containerObserver.ts

getSnapshot: () => (props.newestOnTop ? snapshot.reverse() : snapshot).

Could it be that reverse is done in place? Though it's weird that it works running locally. I tried building the code locally, but haven't had any luck yet, I'm guessing because I'm on Windows.

yarn pack v1.22.22
success Wrote tarball to "react-toastify.tgz".
Done in 0.21s.

[email protected] rm-pkg
rimraf node_modules/react-toastify && mkdir -p node_modules/react-toastify

I was hoping to try and debug it and see if this worked

getSnapshot: () => (props.newestOnTop ? [...snapshot.reverse()] : snapshot).

Don't have much time for it today though. This is a really nice feature that I hope works at some point.

cpfnickhoward added a commit to cpfnickhoward/react-toastify that referenced this issue Sep 26, 2024
Not 100% sure if this is how it should be done, but when I ran things
with this change (both locally and with a build and deployment) it
seemed to work.
@cpfnickhoward
Copy link
Contributor

My previous comment wouldn't fix it, it caused more trouble. I do think I found a fix though. I'm not sure if it's the best approach, but it seems to work.

@fkhadra
Copy link
Owner

fkhadra commented Oct 12, 2024

Looking into it

@fkhadra fkhadra added the bug label Oct 12, 2024
fkhadra pushed a commit that referenced this issue Oct 13, 2024
Not 100% sure if this is how it should be done, but when I ran things
with this change (both locally and with a build and deployment) it
seemed to work.
@fkhadra
Copy link
Owner

fkhadra commented Oct 13, 2024

The fix has been released.

@fkhadra fkhadra closed this as completed Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants