diff --git a/addons/ondevice-controls/src/ControlsPanel.tsx b/addons/ondevice-controls/src/ControlsPanel.tsx index b562f31b5d..7a7cac9634 100644 --- a/addons/ondevice-controls/src/ControlsPanel.tsx +++ b/addons/ondevice-controls/src/ControlsPanel.tsx @@ -48,19 +48,19 @@ const ControlsPanel = ({ api }: { api: API }) => { const storyId = store.getSelection().storyId; const [argsfromHook, updateArgs, resetArgs] = useArgs(storyId, store); const { argTypes, parameters } = store.fromId(storyId); + const argsObject = Object.entries(argsfromHook).reduce((prev, [name, value]) => { + const isControl = Boolean(argTypes?.[name]?.control); - const isArgsStory = parameters.__isArgsStory; - - const hasControls = Object.values(argTypes).some((arg: ArgType) => arg?.control); - const showWarning = !(hasControls && isArgsStory); - const argsObject = hasControls - ? Object.entries(argsfromHook).reduce((prev, [name, value]) => { - return { + return isControl + ? { ...prev, [name]: { ...argTypes?.[name], name, type: argTypes[name]?.control?.type, value }, - }; - }, {}) - : {}; + } + : prev; + }, {}); + const hasControls = Object.keys(argsObject).length > 0; + const isArgsStory = parameters.__isArgsStory; + const showWarning = !(hasControls && isArgsStory); return ( <> diff --git a/examples/native/components/ActionExample/Actions.stories.tsx b/examples/native/components/ActionExample/Actions.stories.tsx index 7230a98809..8407d34132 100644 --- a/examples/native/components/ActionExample/Actions.stories.tsx +++ b/examples/native/components/ActionExample/Actions.stories.tsx @@ -8,6 +8,9 @@ const ActionButtonMeta: ComponentMeta = { argTypes: { onPress: { action: 'pressed the button' }, }, + args: { + text: 'Press me!', + }, }; export default ActionButtonMeta; diff --git a/examples/native/components/ActionExample/Actions.tsx b/examples/native/components/ActionExample/Actions.tsx index d559629af7..d960e3b7b0 100644 --- a/examples/native/components/ActionExample/Actions.tsx +++ b/examples/native/components/ActionExample/Actions.tsx @@ -3,12 +3,13 @@ import { TouchableOpacity, Text, StyleSheet } from 'react-native'; interface ActionButtonProps { onPress: () => void; + text: string; } -export const ActionButton = ({ onPress }: ActionButtonProps) => { +export const ActionButton = ({ onPress, text }: ActionButtonProps) => { return ( - ActionButton + {text} ); };