Skip to content

Commit

Permalink
fix(🐛): Fix regression with transitions (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Apr 29, 2020
1 parent 0ed0d27 commit b84ae5b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/core/src/Transitions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useMemo } from "react";
import Animated, { Easing } from "react-native-reanimated";
import { State } from "react-native-gesture-handler";

import { bin } from "./Math";
import { SpringConfig, TimingConfig } from "./Animations";
import { useValue } from "./Hooks";

const {
Value,
Expand Down Expand Up @@ -98,24 +98,28 @@ export const useTransition = (
state: boolean | number,
config: TimingConfig = {}
) => {
const value = useValue(0);
const value = useMemo(() => new Value(0), []);
useCode(() => set(value, typeof state === "boolean" ? bin(state) : state), [
state,
value,
]);
return withTransition(value, config);
// eslint-disable-next-line react-hooks/exhaustive-deps
const transition = useMemo(() => withTransition(value, config), []);
return transition;
};

export const useSpringTransition = (
state: boolean | number,
config: SpringConfig = defaultSpringConfig
) => {
const value = useValue(0);
const value = useMemo(() => new Value(0), []);
useCode(() => set(value, typeof state === "boolean" ? bin(state) : state), [
state,
value,
]);
return withSpringTransition(value, config);
// eslint-disable-next-line react-hooks/exhaustive-deps
const transition = useMemo(() => withSpringTransition(value, config), []);
return transition;
};

export const useTimingTransition = useTransition;

0 comments on commit b84ae5b

Please sign in to comment.