Skip to content

Commit

Permalink
fix(hooks/usepropserrorboundary.ts): always be error when data props …
Browse files Browse the repository at this point in the history
…set null

fix #34
  • Loading branch information
dohooo committed Nov 18, 2021
1 parent 7221794 commit 2450fe1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/usePropsErrorBoundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ICarouselProps } from 'src/Carousel';
export function usePropsErrorBoundary(props: ICarouselProps<unknown>) {
React.useEffect(() => {
const { defaultIndex, data } = props;
if (typeof defaultIndex === 'number') {
if (typeof defaultIndex === 'number' && data?.length > 0) {
if (defaultIndex < 0 || defaultIndex >= data.length) {
throw Error(
'DefaultIndex must be in the range of data length.'
Expand Down

0 comments on commit 2450fe1

Please sign in to comment.