Skip to content

Commit

Permalink
Merge pull request #185 from Develonaut/patch-1
Browse files Browse the repository at this point in the history
Persist current store value
  • Loading branch information
hipstersmoothie authored Sep 14, 2022
2 parents 3b61d46 + 41a6972 commit 3a2d770
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ export const DarkMode = ({ api }: DarkModeProps) => {
/** When storybook params change update the stored themes */
React.useEffect(() => {
const currentStore = store();

updateStore({ ...currentStore, ...darkModeParams });
// Ensure we use the stores `current` value first to persist
// themeing between page loads and story changes.
updateStore({
...currentStore,
...darkModeParams,
current: currentStore.current || darkModeParams.current,
});
renderTheme()
}, [darkModeParams, renderTheme])

Expand Down

0 comments on commit 3a2d770

Please sign in to comment.