Skip to content

Commit

Permalink
Merge pull request #24268 from storybookjs/norbert/await-setState-in-…
Browse files Browse the repository at this point in the history
…usesharedstate

Core: Fix Promise cycle bug in useSharedState
  • Loading branch information
ndelangen committed Sep 22, 2023
2 parents a12a65b + 25e38c0 commit 45f6153
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/lib/manager-api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ export function useSharedState<S>(stateId: string, defaultState?: S) {
}
});

const setState = (s: S | API_StateMerger<S>, options?: Options) => {
const result = api.setAddonState<S>(stateId, s, options);
const setState = async (s: S | API_StateMerger<S>, options?: Options) => {
const result = await api.setAddonState<S>(stateId, s, options);
STORYBOOK_ADDON_STATE[stateId] = result;
return result;
};
Expand Down

0 comments on commit 45f6153

Please sign in to comment.