Skip to content

Commit

Permalink
chore: added preset prop validator
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Apr 15, 2020
1 parent fb10f48 commit 2a2db45
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 10 additions & 1 deletion src/AnimatedTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface AnimatedTabBarProps
/**
* Animation preset.
*/
preset?: keyof typeof Presets;
preset?: 'bubble';
}

export const AnimatedTabBar = (props: AnimatedTabBarProps) => {
Expand All @@ -49,6 +49,15 @@ export const AnimatedTabBar = (props: AnimatedTabBarProps) => {
isRTL,
} = props;

// verify props
if (!Object.keys(Presets).includes(preset)) {
throw new Error(
`Wrong preset been provided. expected one of these: [${Object.keys(
Presets
).join(', ')}], but found "${preset}".`
);
}

// variables
const isReactNavigation5 = props.state ? true : false;
// @ts-ignore
Expand Down
7 changes: 1 addition & 6 deletions src/bubble/BubbleTabBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useMemo, memo } from 'react';
import { View, ViewStyle, StyleProp } from 'react-native';
import { useSafeArea } from 'react-native-safe-area-context';
import Animated from 'react-native-reanimated';
// @ts-ignore 😞
import isEqual from 'lodash.isequal';
import BubbleTabBarItem from './item';
Expand All @@ -16,10 +15,6 @@ import {
} from './constants';
import { styles } from './styles';

interface BubbleTabBarProps extends TabBarViewProps {
selectedIndex: Animated.Value<number>;
}

const BubbleTabBarComponent = ({
selectedIndex,
routes,
Expand All @@ -30,7 +25,7 @@ const BubbleTabBarComponent = ({
iconSize = DEFAULT_ITEM_ICON_SIZE,
isRTL = DEFAULT_ITEM_LAYOUT_DIRECTION,
style: containerStyleOverride,
}: BubbleTabBarProps) => {
}: TabBarViewProps) => {
//#region Hooks
const safeArea = useSafeArea();
//#endregion
Expand Down
4 changes: 1 addition & 3 deletions src/bubble/item/BubbleTabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ const AnimatedRawButton = createNativeWrapper(

const { add, interpolate, useCode, set, cond, eq } = Animated;

interface BubbleTabBarItemProps extends TabBarItemProps {}

const gestureHandler = (state: Animated.Value<State>) =>
onGestureEvent({ state });

const BubbleTabBarItemComponent = (props: BubbleTabBarItemProps) => {
const BubbleTabBarItemComponent = (props: TabBarItemProps) => {
// props
const {
index,
Expand Down

0 comments on commit 2a2db45

Please sign in to comment.