Skip to content

Commit

Permalink
fix #1176 for real
Browse files Browse the repository at this point in the history
  • Loading branch information
fkhadra committed Dec 16, 2024
1 parent 8defaec commit 0934f94
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/hooks/useToastContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export function useToastContainer(props: ToastContainerProps) {
registerContainer(props)
).current;
setProps(props);
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
const snapshot = useSyncExternalStore(
subscribe,
getSnapshot,
getSnapshot
)?.slice();

function getToastToRender<T>(
cb: (position: ToastPosition, toastList: Toast[]) => T
Expand All @@ -16,9 +20,7 @@ export function useToastContainer(props: ToastContainerProps) {

const toRender = new Map<ToastPosition, Toast[]>();

if (props.newestOnTop) {
snapshot.reverse();
}
if (props.newestOnTop) snapshot.reverse();

snapshot.forEach(toast => {
const { position } = toast.props;
Expand Down

0 comments on commit 0934f94

Please sign in to comment.