diff --git a/examples/reactnavigation/jest-setup.js b/examples/reactnavigation/jest-setup.js new file mode 100644 index 000000000..161b6bc2e --- /dev/null +++ b/examples/reactnavigation/jest-setup.js @@ -0,0 +1,14 @@ +import 'react-native-gesture-handler/jestSetup'; + +jest.mock('react-native-reanimated', () => { + const Reanimated = require('react-native-reanimated/mock'); + + // The mock for `call` immediately calls the callback which is incorrect + // So we override it with a no-op + Reanimated.default.call = () => {}; + + return Reanimated; +}); + +// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing +jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper'); diff --git a/examples/reactnavigation/jest.config.js b/examples/reactnavigation/jest.config.js index e8fd9d396..ec9c1a2a0 100644 --- a/examples/reactnavigation/jest.config.js +++ b/examples/reactnavigation/jest.config.js @@ -1,6 +1,6 @@ module.exports = { preset: 'react-native', - setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'], + setupFiles: ['./jest-setup.js'], transformIgnorePatterns: [ 'node_modules/(?!(jest-)?react-native|@react-native-community|@react-navigation)', ], diff --git a/examples/reactnavigation/package.json b/examples/reactnavigation/package.json index 093ae1542..510afa104 100644 --- a/examples/reactnavigation/package.json +++ b/examples/reactnavigation/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "@react-native-community/masked-view": "^0.1.9", + "@react-navigation/drawer": "^5.11.4", "@react-navigation/native": "^5.1.6", "@react-navigation/stack": "^5.2.13", "prop-types": "^15.7.2", diff --git a/examples/reactnavigation/src/App.js b/examples/reactnavigation/src/App.js index 288feadf4..8e8c32806 100644 --- a/examples/reactnavigation/src/App.js +++ b/examples/reactnavigation/src/App.js @@ -1,3 +1,4 @@ +import 'react-native-gesture-handler'; import React from 'react'; import { StatusBar, StyleSheet, View } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; @@ -9,7 +10,6 @@ export default function App() { - diff --git a/examples/reactnavigation/src/AppNavigator.js b/examples/reactnavigation/src/AppNavigator.js index 3d6ae6135..0f9dcde6e 100644 --- a/examples/reactnavigation/src/AppNavigator.js +++ b/examples/reactnavigation/src/AppNavigator.js @@ -1,4 +1,3 @@ -import 'react-native-gesture-handler'; import * as React from 'react'; import { createStackNavigator } from '@react-navigation/stack'; diff --git a/examples/reactnavigation/src/DrawerApp.js b/examples/reactnavigation/src/DrawerApp.js new file mode 100644 index 000000000..caecc47a5 --- /dev/null +++ b/examples/reactnavigation/src/DrawerApp.js @@ -0,0 +1,13 @@ +import 'react-native-gesture-handler'; +import React from 'react'; +import { NavigationContainer } from '@react-navigation/native'; + +import DrawerAppNavigator from './DrawerAppNavigator'; + +export default function DrawerApp() { + return ( + + + + ); +} diff --git a/examples/reactnavigation/src/DrawerAppNavigator.js b/examples/reactnavigation/src/DrawerAppNavigator.js new file mode 100644 index 000000000..1a57f0ba8 --- /dev/null +++ b/examples/reactnavigation/src/DrawerAppNavigator.js @@ -0,0 +1,35 @@ +import React from 'react'; +import {createDrawerNavigator} from '@react-navigation/drawer'; +import {View, Button, Text} from 'react-native'; + +const { Screen, Navigator } = createDrawerNavigator(); + +function HomeScreen({ navigation }) { + return ( + + Welcome! +