Skip to content
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

feat: openStorybook method & remove async storage & add expo dev menu item #3

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

michalziolkowski
Copy link
Contributor

@michalziolkowski michalziolkowski commented Mar 22, 2024

openStorybook method

If user is using withStorybook hoc they can use openStorybook method from anywhere in the app to enter Storybook mode, they can do it by using the useSherlo hook

const App = () => {
    const { openStorybook } = useSherlo();

    return (
      <View>
        <Text style={{ textAlign: 'center' }}>
          {'Open Dev Menu and select "Toggle Storybook" \nor click the button below'}
        </Text>
        <Button title="Open Storybook" onPress={openStorybook} />
      </View>
    );
  };

remove async storage

We no more require from users to install @react-native-async-storage/async-storage along with sherlo dependencies. We used this storage to hold state if the storybook mode is enabled or not. Now we rely on methods provided by user when configuring Storybook itself - storage, if they provide storage methods the functionality of holding state between restart of the app will be supported

import { withSherlo } from '@sherlo/react-native-storybook';
import { view } from './storybook.requires';
import AsyncStorage from '@react-native-async-storage/async-storage';

const StorybookUIRoot = withSherlo(view, {
storage: {
  getItem: AsyncStorage.getItem,
  setItem: AsyncStorage.setItem,
},
});

export default StorybookUIRoot;

expo dev menu item

This is only available in development builds right now but user can open their dev menu and select "Toggle Storybook" list item to control visibility of Storybook, just like bare React Native user can do it from RN Dev menu

@michalziolkowski michalziolkowski changed the title feat: Provide openStorybook method & remove async storage dependency feat: openStorybook method & remove async storage & add expo dev menu item Mar 22, 2024
@michalziolkowski michalziolkowski merged commit fbb61ed into dev Mar 22, 2024
3 checks passed
@dawidk92 dawidk92 deleted the michal/dev-menu-and-persistence branch July 10, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants