Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error when assigning readonly Matrix to mutable shared value in react-native-reanimated #510

Open
demedos opened this issue Sep 18, 2023 · 0 comments

Comments

@demedos
Copy link

demedos commented Sep 18, 2023

As Matrix4 is declared as a readonly array, it is impossibile to re-assign it as an AnimatableValue and to properly animate some transitions. I know this is expected behavior, but any idea on how to implement the following code maintaining the readonly type safety?

Code example:

import { useSharedValue, withTiming } from 'react-native-reanimated';
import { identity4 } from 'react-native-redash';

const matrix = useSharedValue(identity4); // matrix is expected to be mutable
matrix.value = withTiming(identity4); // This assignment attempts to assign a readonly array to a mutable one

Error:

Argument of type 'Matrix4' is not assignable to parameter of type 'AnimatableValue'.
The type 'readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]' is 'readonly' and cannot be assigned to the mutable type 'number[]'.ts(2345)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant