React-spring: TypeScript error with `useSprings` hook's `setSpring`

Created on 18 Nov 2019  路  2Comments  路  Source: pmndrs/react-spring

Hello!

I am getting this error when I try to pass a function to setSprings as a parameter.
Screen Shot 2019-11-18 at 19 33 11

However, it's working fine even if it is showing this.

Here is the body of the error message:

(parameter) index: number
No overload matches this call.
  Overload 1 of 2, '(ds: Partial<Merge<{ backgroundColor: string; } & UseSpringBaseProps, { from?: Partial<Pick<{ backgroundColor: string; }, "backgroundColor">> | undefined; onRest?(ds: Partial<...>): void; }>>): void', gave the following error.
    Value of type '(index: number) => { backgroundColor: string; }' has no properties in common with type 'Partial<Merge<{ backgroundColor: string; } & UseSpringBaseProps, { from?: Partial<Pick<{ backgroundColor: string; }, "backgroundColor">> | undefined; onRest?(ds: Partial<...>): void; }>>'. Did you mean to call it?
  Overload 2 of 2, '(i: number): Partial<Merge<{ backgroundColor: string; } & UseSpringBaseProps, { from?: Partial<Pick<{ backgroundColor: string; }, "backgroundColor">> | undefined; onRest?(ds: Partial<...>): void; }>>', gave the following error.
    Argument of type '(index: number) => { backgroundColor: string; }' is not assignable to parameter of type 'number'.ts(2769)
question

Most helpful comment

Please try with v9:

npm install react-spring@next

All 2 comments

Please try with v9:

npm install react-spring@next

Had the same problem, confirming V9 is fixing it.

Was this page helpful?
0 / 5 - 0 ratings