React-native-reanimated: ClockNode cannot be found on Android

Created on 22 Jan 2020  路  2Comments  路  Source: software-mansion/react-native-reanimated

I'm getting this error on Android, on iOS it works fine. Here is the code responsible for starting the clock.

d3c2e75c-6525-46fd-a943-b9238c146d4a

const {
      Value,
      Clock,
      and,
      block,
      cond,
      lessThan,
      greaterThan,
      greaterOrEq,
      interpolate,
      lessOrEq,
      abs,
      set,
      useCode,
      event,
      add,
      eq,
      divide,
      multiply,
      diff,
      startClock,
      stopClock,
      decay,
      not,
      spring,
      sub,
      min,
      pow,
      debug
    } = Animated;


    const withScroll = ({
      translationX,
      velocityX,
      state: gestureState,
      tabsWidth,
      containerWidth,
      tabs,
      positions,
      indexTransition,
      index
    }) => {
      const clock = new Clock();
      const delta = new Value(0);
      const isSpringing = new Value(0);
      const state = {
        time: new Value(0),
        position: new Value(0),
        velocity: new Value(0),
        finished: new Value(0)
      };
      const activeIndex = index;
      const activeIndexTransition = withTransition(index);
      const isIndexUpdated = new Value(0);
      const upperBound = 0;
      const lowerBound = -1 * (tabsWidth - containerWidth);
      const isInBound = and(
        lessOrEq(state.position, upperBound),
        greaterOrEq(state.position, lowerBound)
      );
      const config = {
        stiffness: new Value(100),
        mass: new Value(1),
        damping: new Value(14),
        overshootClamping: false,
        restSpeedThreshold: 0.001,
        restDisplacementThreshold: 0.001,
        toValue: new Value(0)
      };
      const overscroll = sub(
        state.position,
        cond(greaterOrEq(state.position, 0), upperBound, lowerBound)
      );

      return block([
        startClock(clock),
        set(delta, diff(translationX)),
        cond(
          eq(gestureState, State.ACTIVE),
          [
            set(isSpringing, 0),
            set(isIndexUpdated, 0),
            set(
              state.position,
              add(
                state.position,
                cond(
                  isInBound,
                  delta,
                  multiply(
                    delta,
                    friction(min(divide(abs(overscroll), containerWidth), 1))
                  )
                )
              )
            ),
            set(state.velocity, velocityX),
            set(state.time, 0)
          ],
          [
            set(translationX, 0),
            cond(
              diff(activeIndexTransition),
              [
                set(
                  state.position,
                  interpolate(activeIndexTransition, {
                    inputRange: tabs.map((_tab, i) => i),
                    outputRange: positions.map((value, index) => {
                      return -1 * value;
                    })
                  })
                ),
                set(isIndexUpdated, 1)
              ],
              [
                cond(
                  and(isInBound, not(isSpringing)),
                  [decay(clock, state, { deceleration: 0.997 })],
                  [
                    cond(not(isIndexUpdated), [
                      set(isSpringing, 1),
                      set(state.finished, 0),
                      set(
                        config.toValue,
                        snapPoint(state.position, state.velocity, [
                          lowerBound,
                          upperBound
                        ])
                      ),
                      spring(clock, state, config),
                      cond(state.finished, set(isSpringing, 0))
                    ])
                  ]
                )
              ]
            )
          ]
        ),
        state.position
      ]);
    };

Most helpful comment

@igarcido95 how did you solved this error? Exactly the same situation for me on android..

All 2 comments

@igarcido95 how did you solved this error? Exactly the same situation for me on android..

@vitosorriso did you find a solution 馃 ?

Was this page helpful?
0 / 5 - 0 ratings