wcandillon / react-native-redash

The React Native Reanimated and Gesture Handler Toolbelt
https://wcandillon.gitbook.io/redash/
MIT License
1.97k stars 117 forks source link

Can't cast NoopNode to ClockNode on Android #402

Open dev-andremonteiro opened 3 years ago

dev-andremonteiro commented 3 years ago

Hi! I have been unable to upgrade expo to v39 because of an error we were getting when using reanimated ~1.13.0, after some debugging I got to the root of the cause and it was the delay function in your library, here's the code I used to replicate this error: "react-native-reanimated": "~1.13.0", "react-native-redash": "14.2.4",

function runTiming(
  clock: Animated.Clock,
  value: Animated.Value<number>,
  dest: number,
  dur: number,
  delay = 0                  **// To make it work we need to change the default delay value to 1** 
) {
  const inDelay = new Value(1);
  const state: Animated.TimingState = {
    finished: new Value(0),
    position: new Value(0),
    time: new Value(0),
    frameTime: new Value(0)
  };

  const config: Animated.TimingConfig = {
    duration: dur,
    toValue: new Value(0),
    easing: Easing.linear
  };

  return block([
    RedashDelay(set(inDelay, 0), delay),
    cond(not(inDelay), [
      cond(clockRunning(clock), 0, [
        set(state.finished, 0),
        set(state.time, 0),
        set(state.position, value),
        set(state.frameTime, 0),
        set(config.toValue, dest),
        startClock(clock)
      ]),
      timing(clock, state, config),
      cond(state.finished, [stopClock(clock)])
    ]),
    state.position
  ]);
}

It works with reanimated ~1.9.0.

The error message just shows : "Can't cast NoopNode to ClockNode" so I couldn't rely on that to guide me, please let me know if you need anything else. Thank you for your service!

dev-andremonteiro commented 3 years ago

Just tested it within a Simpler Component and it seems like RedashDelay( ... , delay) always throws an error if delay is equal to zero, just create a simple translate animation and add the RedashDelay function inside the block component and we get that error. Just to make sure it's all clear I have this as my import statement : import { delay as RedashDelay } from 'react-native-redash';