Skip to content

Commit

Permalink
fix: Sync the external Storybook parameters once, not every render
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Jacobs committed Mar 3, 2023
1 parent 0f4e275 commit 4354144
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/react-native/src/preview/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export class View {
const self = this;

const appliedTheme = deepmerge(theme, params.theme ?? {});
// Sync the Storybook parameters (external) with app UI state (internal), to initialise them.
syncExternalUI({
isUIVisible: params.isUIHidden !== undefined ? !params.isUIHidden : undefined,
isSplitPanelVisible: params.isSplitPanelVisible,
});

return () => {
const setContext = useSetStoryContext();
const [, forceUpdate] = useReducer((x) => x + 1, 0);
Expand All @@ -174,11 +180,6 @@ export class View {
}, []);

if (onDeviceUI) {
syncExternalUI({
isUIVisible: params.isUIHidden !== undefined ? !params.isUIHidden : undefined,
isSplitPanelVisible: params.isSplitPanelVisible,
});

return (
<SafeAreaProvider>
<ThemeProvider theme={appliedTheme}>
Expand Down

0 comments on commit 4354144

Please sign in to comment.