Skip to content

Commit

Permalink
Restore isConfigured function (#4832)
Browse files Browse the repository at this point in the history
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

`isConfigured` was an internal check that due it's directory's
`index.ts` having `export * from ./core` was available as a direct
import from `react-native-reanimated`. Therefore we cannot simply remove
it in a minor version - deleting it raised
react-navigation/react-navigation#11498,
`react-navigation` uses this function
[here](https://github.com/react-navigation/react-navigation/blob/24c03924397a6e59aba9f6b74a9c5cb4b939d9e1/packages/react-native-drawer-layout/src/views/Drawer.tsx#L56)
to detect Reanimated 3 since Reanimated 2 didn't have this function.

This PR restores this function, marks it as deprecated and adds a
separate `public` check to detect Reanimated 3.

## Test plan

🚀

## Note

We should probably locate more functions that are exported as a part of
public API but they shouldn't be.
  • Loading branch information
tjzel authored and piaskowyk committed Jul 27, 2023
1 parent a678f4c commit a91019b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/reanimated2/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ export type ReanimatedConsole = Pick<
'debug' | 'log' | 'warn' | 'info' | 'error'
>;

/**
* @returns `true` in Reanimated 3, doesn't exist in Reanimated 2 or 1
*/
export const isReanimated3 = () => true;

// Superseded by check in `/src/threads.ts`.
// Used by `react-navigation` to detect if using Reanimated 2 or 3.
/**
* @deprecated This function was superseded by other checks.
* We keep it here for backward compatibility reasons.
* If you need to check if you are using Reanimated 3 or Reanimated 2
* please use `isReanimated3` function instead.
* @returns `true` in Reanimated 3, doesn't exist in Reanimated 2
*/
export const isConfigured = isReanimated3;

// this is for web implementation
global._WORKLET = false;
global._log = function (s: string) {
Expand Down

0 comments on commit a91019b

Please sign in to comment.