Skip to content

Instantly share code, notes, and snippets.

@marlonschlosshauer
Created December 23, 2022 15:31
Show Gist options
  • Select an option

  • Save marlonschlosshauer/ee51b154365b84c5512c87c54497d059 to your computer and use it in GitHub Desktop.

Select an option

Save marlonschlosshauer/ee51b154365b84c5512c87c54497d059 to your computer and use it in GitHub Desktop.
Storybook Decorator to use React (Native) Navigation
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
const Stack = createNativeStackNavigator();
export const withNavigation = (story: () => JSX.Element) => {
const Screen = () => story();
return (
<NavigationContainer independent={true}>
<Stack.Navigator>
<Stack.Screen name="Dummy" component={Screen} options={{ header: () => null }} />
</Stack.Navigator>
</NavigationContainer>
)
}
@marlonschlosshauer
Copy link
Author

Mostly taken from this post on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment