Skip to content

Commit 2450fe1

Browse files
committed
fix(hooks/usepropserrorboundary.ts): always be error when data props set null
fix #34
1 parent 7221794 commit 2450fe1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/hooks/usePropsErrorBoundary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ICarouselProps } from 'src/Carousel';
44
export function usePropsErrorBoundary(props: ICarouselProps<unknown>) {
55
React.useEffect(() => {
66
const { defaultIndex, data } = props;
7-
if (typeof defaultIndex === 'number') {
7+
if (typeof defaultIndex === 'number' && data?.length > 0) {
88
if (defaultIndex < 0 || defaultIndex >= data.length) {
99
throw Error(
1010
'DefaultIndex must be in the range of data length.'

0 commit comments

Comments
 (0)