From ca8b869ef73ef682500bec96babaad8f9e362f7e Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Fri, 8 Sep 2023 14:14:45 +0200 Subject: [PATCH] provide correct parseContent --- packages/demo/src/components/FieldPluginDemo.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/demo/src/components/FieldPluginDemo.tsx b/packages/demo/src/components/FieldPluginDemo.tsx index d9c87385..1cf3fbe9 100644 --- a/packages/demo/src/components/FieldPluginDemo.tsx +++ b/packages/demo/src/components/FieldPluginDemo.tsx @@ -6,7 +6,9 @@ import { useFieldPlugin } from '@storyblok/field-plugin/react' import { ModalView } from './ModalView' import { NonModalView } from './NonModalView' -type Content = unknown +const parseContent = (content: unknown) => + typeof content === 'number' ? content : 0 +type Content = ReturnType export type PluginComponent = FunctionComponent<{ data: FieldPluginData @@ -15,7 +17,7 @@ export type PluginComponent = FunctionComponent<{ export const FieldPluginDemo: FunctionComponent = () => { const { type, data, actions } = useFieldPlugin({ - parseContent: (content: Content) => content, + parseContent, }) if (type === 'loading') {