• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fkhadra / react-toastify / 12001201729

25 Nov 2024 12:54AM UTC coverage: 42.537% (-46.5%) from 88.998%
12001201729

Pull #1178

github

fkhadra
bump coverall action
Pull Request #1178: [WIP] V11

141 of 375 branches covered (37.6%)

Branch coverage included in aggregate %.

3 of 5 new or added lines in 3 files covered. (60.0%)

214 existing lines in 9 files now uncovered.

201 of 429 relevant lines covered (46.85%)

176.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/hooks/useToastContainer.ts
1
import { useRef, useSyncExternalStore } from 'react';
2
import { isToastActive, registerContainer } from '../core/store';
3
import { Toast, ToastContainerProps, ToastPosition } from '../types';
4

5
export function useToastContainer(props: ToastContainerProps) {
UNCOV
6
  const { subscribe, getSnapshot, setProps } = useRef(
×
7
    registerContainer(props)
8
  ).current;
UNCOV
9
  setProps(props);
×
NEW
10
  const snapshot = useSyncExternalStore(
×
11
    subscribe,
12
    getSnapshot,
13
    getSnapshot
14
  )?.slice();
15

16
  function getToastToRender<T>(
17
    cb: (position: ToastPosition, toastList: Toast[]) => T
18
  ) {
UNCOV
19
    if (!snapshot) return [];
×
20

UNCOV
21
    const toRender = new Map<ToastPosition, Toast[]>();
×
22

NEW
23
    if (props.newestOnTop) snapshot.reverse();
×
24

UNCOV
25
    snapshot.forEach(toast => {
×
UNCOV
26
      const { position } = toast.props;
×
UNCOV
27
      toRender.has(position) || toRender.set(position, []);
×
UNCOV
28
      toRender.get(position)!.push(toast);
×
29
    });
30

UNCOV
31
    return Array.from(toRender, p => cb(p[0], p[1]));
×
32
  }
33

UNCOV
34
  return {
×
35
    getToastToRender,
36
    isToastActive,
37
    count: snapshot?.length
38
  };
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc