Skip to content

Commit

Permalink
chore: added effect to keep navigation state and selected index synced
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Mar 29, 2020
1 parent ab83e59 commit 09982ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AnimatedTabBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from 'react';
import React, { useCallback, useMemo, useEffect } from 'react';
import { View } from 'react-native';
import Animated, { useCode, onChange, call } from 'react-native-reanimated';
import { useValues } from 'react-native-redash';
Expand Down Expand Up @@ -59,6 +59,11 @@ export const AnimatedTabBar = (props: AnimatedTabBarProps) => {
);

// effects
useEffect(() => {
// @ts-ignore
selectedIndex.setValue(state.index);
}, [state, selectedIndex]);

useCode(
() =>
onChange(
Expand Down

0 comments on commit 09982ca

Please sign in to comment.