Skip to content

Commit

Permalink
fix: add helpful error when using legacy implementation with Reanimat…
Browse files Browse the repository at this point in the history
…ed v3 (#10693)

**Motivation**

As Reanimated 3 will not support Reanimated 1 syntax anymore we need to show a helpful message describing the problem.

This PR adds an error

```
The `useLegacyImplementation` prop is not available with Reanimated 3 as it no longer includes support for Reanimated 1 legacy API. Remove the `useLegacyImplementation` prop from `Drawer.Navigator` to be able to use it.
```

when trying to use legacy drawer implementation with Reanimated 3.


Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
  • Loading branch information
kacperkapusciak and satya164 committed Nov 27, 2022
1 parent 9636516 commit 23df654
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/drawer/src/views/DrawerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ function DrawerViewBase({
// @ts-expect-error: the type definitions are incomplete
useLegacyImplementation = !Reanimated.isConfigured?.(),
}: Props) {
// Reanimated v3 dropped legacy v1 syntax
const legacyImplemenationNotAvailable =
require('react-native-reanimated').abs === undefined;

if (useLegacyImplementation && legacyImplemenationNotAvailable) {
throw new Error(
'The `useLegacyImplementation` prop is not available with Reanimated 3 as it no longer includes support for Reanimated 1 legacy API. Remove the `useLegacyImplementation` prop from `Drawer.Navigator` to be able to use it.'
);
}

const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation
? require('./legacy/Drawer').default
: require('./modern/Drawer').default;
Expand Down

0 comments on commit 23df654

Please sign in to comment.