Skip to content

Commit 5f1d914

Browse files
committed
fix: options is null should not crash
1 parent 811f94d commit 5f1d914

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/generate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export default function generateSelector<
375375
);
376376
}
377377

378-
return newOptions;
378+
return newOptions || ([] as OptionsType);
379379
}, [options, children, mode, baseValue]);
380380

381381
const mergedFlattenOptions: FlattenOptionsType<OptionsType> = React.useMemo(

tests/Select.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,4 +1312,8 @@ describe('Select.Basic', () => {
13121312
errorSpy.mockRestore();
13131313
});
13141314
});
1315+
1316+
it('not crash when options is null', () => {
1317+
mount(<Select options={null} />);
1318+
});
13151319
});

0 commit comments

Comments
 (0)