Skip to content

Commit

Permalink
add missing dependency in useEffect hook
Browse files Browse the repository at this point in the history
this was causing browsers to crash
  • Loading branch information
yannbf committed Sep 24, 2023
1 parent cf3fdaf commit 0c783b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions code/lib/manager-api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import mergeWith from 'lodash/mergeWith.js';
import type {
Expand Down Expand Up @@ -397,19 +398,18 @@ export function useSharedState<S>(stateId: string, defaultState?: S) {
existingState,
STORYBOOK_ADDON_STATE[stateId] ? STORYBOOK_ADDON_STATE[stateId] : defaultState
);

let quicksync = false;
let quickSync = false;

if (state === defaultState && defaultState !== undefined) {
STORYBOOK_ADDON_STATE[stateId] = defaultState;
quicksync = true;
quickSync = true;
}

useEffect(() => {
if (quicksync) {
if (quickSync) {
api.setAddonState<S>(stateId, defaultState);
}
});
}, [quickSync]);

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

0 comments on commit 0c783b7

Please sign in to comment.