InvokeAI/invokeai/frontend/web/.storybook/ReduxInit.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
762 B
TypeScript
Raw Normal View History

2023-12-29 03:05:56 +00:00
import { PropsWithChildren, memo, useEffect } from 'react';
import { modelChanged } from '../src/features/controlLayers/store/canvasV2Slice';
import { useAppDispatch } from '../src/app/store/storeHooks';
2024-01-27 09:53:32 +00:00
import { useGlobalModifiersInit } from '@invoke-ai/ui-library';
/**
* Initializes some state for storybook. Must be in a different component
* so that it is run inside the redux context.
*/
2023-12-29 03:05:56 +00:00
export const ReduxInit = memo((props: PropsWithChildren) => {
const dispatch = useAppDispatch();
useGlobalModifiersInit();
useEffect(() => {
2024-06-16 02:45:05 +00:00
dispatch(
modelChanged({ model: { key: 'test_model', hash: 'some_hash', name: 'some name', base: 'sd-1', type: 'main' } })
);
}, []);
return props.children;
2023-12-29 03:05:56 +00:00
});
ReduxInit.displayName = 'ReduxInit';