diff --git a/code/addons/actions/src/manager.tsx b/code/addons/actions/src/manager.tsx index 95473221160d..434e214de30a 100644 --- a/code/addons/actions/src/manager.tsx +++ b/code/addons/actions/src/manager.tsx @@ -1,22 +1,22 @@ -import React, { useState } from 'react'; -import { addons, types, useChannel } from '@storybook/manager-api'; +import React from 'react'; +import { addons, types, useAddonState, useChannel } from '@storybook/manager-api'; import { STORY_CHANGED } from '@storybook/core-events'; import { Badge, Spaced } from '@storybook/components'; import ActionLogger from './containers/ActionLogger'; import { ADDON_ID, CLEAR_ID, EVENT_ID, PANEL_ID, PARAM_KEY } from './constants'; function Title() { - const [count, setCount] = useState(0); + const [{ count }, setCount] = useAddonState(ADDON_ID, { count: 0 }); useChannel({ [EVENT_ID]: () => { - setCount((c) => c + 1); + setCount((c) => ({ ...c, count: c.count + 1 })); }, [STORY_CHANGED]: () => { - setCount(0); + setCount((c) => ({ ...c, count: 0 })); }, [CLEAR_ID]: () => { - setCount(0); + setCount((c) => ({ ...c, count: 0 })); }, });