-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Potential TypeScript errors in react-native-reanimated 3.4.0 #4645
Comments
I tried the We store some shared values in a context, but the context default values are not proper shared values objects, as (afaik) you can not create share values outside of a component. We initialize them with Example: export const myContext = createContext<{ counter: SharedValue<number> }>({
counter: { value: 0 },
})
// Then used like this:
const Component: React.FC = () => {
const counter = useSharedValue(0)
return (
<myContext.Provider value={{ counter }}>
{/* … */}
</myContext.Provider>
)
} This fails with the following error:
|
Hi @renchap. From my personal experience I also found default values for export const myContext = createContext<{ counter: SharedValue<number> }>({
counter: undefined as unknown as SharedValue<number>,
}) I know it's not pretty, but you could make it better: interface myContextType {
counter: SharedValue<number>;
}
export const myContext = createContext<myContextType>(
{} as myContextType
); Which I think is much more elegant. |
@aliza-khu About the release, I believe it may require a few additional weeks. With regards to the issue you raised, we will make every effort to fix it before the release, provided that we have sufficient time. If you have any ideas for a desired fix, we would be delighted if you could open a pull request. Lastly, I kindly request that you avoid including non-TypeScript problems in this issue to ensure that all matters are handled systematically. |
Hello ! I tried the nightly package in our app as well, and I've encountered an issue when trying to provide an adapter created through Example: This example from the docs would raises the same error we have : https://reanimated-beta-docs.swmansion.com/docs/core/useAnimatedProps#adapters- It fails with the following error:
Please let me know if there's more I can do ! |
@jblarriviere Thanks for pointing that out! Adapters are quite complex and so far I had to cast it to old |
You may need to update your version of |
@devoren it seems like your FlashList doesn't have its item's types but renderItem is typed. Could you show a code snippet that leads to it? |
@tjzel Component:
|
@devoren I'm afraid a definition for |
@tjzel Sorry to bother you, after changing the type everything works here: |
@devoren No problems, I'm glad to see that it works since types for |
I get an error when giving types for useAnimatedRef and Animated.FlatList,
or
and this is the error
|
The same issue "react-native-reanimated":"3.5.4" |
I'm also getting this one. "react-native": "0.72.5", |
AnimatedRef & FlatList error will be fixed with #5308. |
Hi @satya164, which versions should I upgrade till? I'm still facing this error.
|
missing semicolon in FlatList.tsx error is still coming on the latest version (3.5.4) + RN(0.70.12). Anyone able to have a proper fix for it ? |
It seems the It seems this happens because I'm explicitly importing I fixed this by adding a
But something similar should be automatically included in the types for reanimated. |
@dmontag23 We will look into it. |
Closing this issue since collective TS errors stemming from 3.4.0 are resolved. Please open new issues for new TS errors. As for those semicolons @manjeetcars24, try upgrading your TypeScript and maybe React Native. |
Still having |
@AntQwanlity Try bumping your TypeScript to 4.7 at least. |
The same. |
Typescript 5.3 |
@AntQwanlity Check out solutions in here |
want to flag that I ran into this issue after creating a managed expo app in a monorepo:
the root cause was because I moved the moving from the root into each package's |
Had to remove an outdated ui library that used a older react-native-reanimated version. That's fixed it for me. Run |
Description
This issue is dedicated for all
react-native-reanimated
users that have upgraded to 3.4.0. We made a significant change in which we remove old, manually typed definition filereact-native-reanimated.d.ts
to use automatically generated.d.ts
files.However, the code base is complex enough that full transition could not be done all at once and some type errors are to be expected. Therefore, please report your type problems in this issue, so we could have them all in one place.
Moreover, if issues that emerged are too burdensome for you to keep up smooth development with
react-native-reanimated
we've prepared a quick guide on how to revert those changes, until the fixes come.This is a special branch that is the current version of
react-native-reanimated
but doesn't use automatically generated types. Keep in mind, that this version is also not type errors free and we don't plan on improving it, since its maintenance is too time consuming.How to restore previous typings in react-native-reanimated
CLI solve
Manual solve
package.json
(make sure it's the file that's in the root of repository)react-native-reanimated.d.ts
node_modules/react-native-reanimated
in your project files.Steps to reproduce
react-native-reanimated
to3.4.0
.Reanimated version
3.4.0
Platforms
Android, iOS, Web
The text was updated successfully, but these errors were encountered: