From 4354144d26ac4da6e197b66d00db6ae1986f48be Mon Sep 17 00:00:00 2001 From: Jonathan Jacobs Date: Fri, 3 Mar 2023 17:49:26 +0200 Subject: [PATCH] fix: Sync the external Storybook parameters once, not every render --- app/react-native/src/preview/View.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/react-native/src/preview/View.tsx b/app/react-native/src/preview/View.tsx index 2172f9faca..d79a745acd 100644 --- a/app/react-native/src/preview/View.tsx +++ b/app/react-native/src/preview/View.tsx @@ -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); @@ -174,11 +180,6 @@ export class View { }, []); if (onDeviceUI) { - syncExternalUI({ - isUIVisible: params.isUIHidden !== undefined ? !params.isUIHidden : undefined, - isSplitPanelVisible: params.isSplitPanelVisible, - }); - return (