Skip to content

Commit 6ad85b4

Browse files
zombieJclaude
andcommitted
refactor: simplify ref handling with composeRef and clean up wrapper styles
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ddedd92 commit 6ad85b4

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/NotificationList.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Notification, {
1313
import useListPosition from './hooks/useListPosition';
1414
import useListScroll from './hooks/useListScroll';
1515
import useStack from './hooks/useStack';
16+
import { composeRef } from '@rc-component/util/lib/ref';
1617

1718
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
1819
export type { StackConfig } from './interface';
@@ -165,29 +166,21 @@ const NotificationList: React.FC<NotificationListProps> = (props) => {
165166
const { key, placement: _placement, ...notificationConfig } = config;
166167
const strKey = String(key);
167168

169+
const setItemRef = (node: HTMLDivElement | null) => {
170+
setNodeSize(strKey, node);
171+
};
172+
168173
return (
169174
<div
170-
key={key}
171-
className={clsx(
172-
noticeWrapperCls,
173-
itemPrefixCls,
174-
motionClassName,
175-
classNames?.wrapper,
176-
config.classNames?.wrapper,
177-
)}
178-
ref={(node) => {
179-
assignRef(nodeRef, node);
180-
setNodeSize(strKey, node);
181-
}}
175+
className={clsx(noticeWrapperCls, itemPrefixCls, motionClassName)}
182176
style={{
183177
...motionStyle,
184-
...styles?.wrapper,
185-
...config.styles?.wrapper,
186178
}}
187179
>
188180
<Notification
189-
key={config.times}
181+
key={key}
190182
{...notificationConfig}
183+
ref={composeRef(nodeRef, setItemRef)}
191184
prefixCls={prefixCls}
192185
offset={notificationPosition.get(strKey)}
193186
className={clsx(contextClassNames?.notice, config.className)}

0 commit comments

Comments
 (0)