Skip to content

Commit

Permalink
Revert "fix: notification memory leak (#361)"
Browse files Browse the repository at this point in the history
This reverts commit 6811a31.
  • Loading branch information
MadCcc committed Sep 27, 2024
1 parent c8eb62a commit 7806659
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/NoticeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
const { classNames: ctxCls } = useContext(NotificationContext);

const dictRef = useRef<Record<string, HTMLDivElement>>({});
const latestNoticeRef = useRef<HTMLDivElement>(null);
const [latestNotice, setLatestNotice] = useState<HTMLDivElement>(null);
const [hoverKeys, setHoverKeys] = useState<string[]>([]);

const keys = configList.map((config) => ({
Expand All @@ -72,7 +72,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
// Force update latest notice
useEffect(() => {
if (stack && dictRef.current[keys[keys.length - 1]?.key]) {
latestNoticeRef.current = dictRef.current[keys[keys.length - 1]?.key];
setLatestNotice(dictRef.current[keys[keys.length - 1]?.key]);
}
}, [keys, stack]);

Expand Down Expand Up @@ -115,7 +115,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
if (index > 0) {
stackStyle.height = expanded
? dictRef.current[strKey]?.offsetHeight
: latestNoticeRef.current?.offsetHeight;
: latestNotice?.offsetHeight;

// Transform
let verticalOffset = 0;
Expand All @@ -126,8 +126,8 @@ const NoticeList: FC<NoticeListProps> = (props) => {
const transformY =
(expanded ? verticalOffset : index * offset) * (placement.startsWith('top') ? 1 : -1);
const scaleX =
!expanded && latestNoticeRef.current?.offsetWidth && dictRef.current[strKey]?.offsetWidth
? (latestNoticeRef.current?.offsetWidth - offset * 2 * (index < 3 ? index : 3)) /
!expanded && latestNotice?.offsetWidth && dictRef.current[strKey]?.offsetWidth
? (latestNotice?.offsetWidth - offset * 2 * (index < 3 ? index : 3)) /

Check warning on line 130 in src/NoticeList.tsx

View check run for this annotation

Codecov / codecov/patch

src/NoticeList.tsx#L130

Added line #L130 was not covered by tests
dictRef.current[strKey]?.offsetWidth
: 1;
stackStyle.transform = `translate3d(${transformX}, ${transformY}px, 0) scaleX(${scaleX})`;
Expand Down

0 comments on commit 7806659

Please sign in to comment.