React-native-reanimated: TypeScript error "Type 'AnimatedNode<number>' provides no match for the signature" with useCode / block()

Created on 17 Nov 2019  路  2Comments  路  Source: software-mansion/react-native-reanimated

Hi,

I'm getting this error with the latest version of reanimated and react-native.
Argument of type 'AnimatedNode<number>' is not assignable to parameter of type '() => AnimatedNode<number>'.

Any idea how I can prevent/fix this error?

  const { time, clock, progress } = useMemoOne(() => ({
    clock: new Clock(),
    time: new Value(0),
    progress: new Value(0),
   }), []);

  useCode(
    block([
     cond(not(clockRunning(clock)), [
        startClock(clock),
        set(time, clock),
      ]),
      set(progress, interpolate(clock, {
        inputRange: [time, add(time, duration)],
        outputRange: [0, 1],
        extrapolate: Extrapolate.CLAMP,
      })),
      cond(eq(progress, 1), stopClock(clock)),
    ]),
    [],
  );

Screenshot 2019-11-16 at 12 10 22

My tsconfig is;

{
  "compilerOptions": {
    "lib": ["es2017"],
    "target": "esnext",
    "jsx": "react-native",
    "moduleResolution": "node",
    "baseUrl": "./",
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "isolatedModules": true,
    "strict": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "noEmit": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "paths": {
        ...
    },
    "typeRoots": ["node_modules/@types"],
  },
  "exclude": ["node_modules", "**/*.json", "**/*.spec.ts"]
}

The same error get's triggered because of useCode in libraries like react-native-redash in the folder src/Animations

Most helpful comment

Hello,

Is it because now useCode takes a callback as parameter? useCode(() => block()) Redash only works with 1.2.0 for now.

All 2 comments

Hello,

Is it because now useCode takes a callback as parameter? useCode(() => block()) Redash only works with 1.2.0 for now.

Now I read to error again this makes sense, but couldn't figure it out back then.. Thanks for pointing this out.

Was this page helpful?
0 / 5 - 0 ratings