Skip to content

Commit 678403c

Browse files
thinkasanyafc163
andauthored
fix: tipFormatter should not crash with undefined value (#1053)
* fix: tipFormatter should not crash with undefined value * fix * fix: tacks crash * Update tests/Slider.test.js --------- Co-authored-by: afc163 <[email protected]>
1 parent 29c1850 commit 678403c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Tracks/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const Tracks: React.FC<TrackProps> = (props) => {
4747

4848
// ========================== Render ==========================
4949
const tracksNode =
50-
classNames.tracks || styles.tracks ? (
50+
trackList?.length && (classNames.tracks || styles.tracks) ? (
5151
<Track
5252
index={null}
5353
prefixCls={prefixCls}

tests/Slider.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,10 @@ describe('Slider', () => {
662662
const { asFragment } = render(<Slider included={false} />);
663663
expect(asFragment().firstChild).toMatchSnapshot();
664664
});
665+
666+
it('tipFormatter should not crash with undefined value', () => {
667+
[undefined, null].forEach((value) => {
668+
render(<Slider value={value} tooltip={{ open: true }} styles={{ tracks: {} }}/>);
669+
});
670+
});
665671
});

0 commit comments

Comments
 (0)