addon-controls - how do I update an arg from a function prop #12647
Answered
by
FranciscoG
FranciscoG
asked this question in
Help
-
I have this component that takes a function prop which passes back a variable in its parameters and I need to set a different arg in the same component using that param export const Usage = (args) => {
return (
<ImageUpload
{...args}
onImageSelected={(file) => {
// I need to set `args.src` to this `file` but not sure how
}}
/>
);
};
Usage.args = {
width: 128,
height: 128,
src: "https://picsum.photos/seed/barrel/215/215",
}; is this possible? |
Beta Was this translation helpful? Give feedback.
Answered by
FranciscoG
Nov 15, 2020
Replies: 1 comment 1 reply
-
I figured this out by using export const Usage = (args) => {
const [src, setSrc] = useState(args.src);
return (
<ImageUpload
{...args}
src={src}
onImageSelected={(file) => {
setSrc(file)
}}
/>
);
};
Usage.args = {
width: 128,
height: 128,
src: "https://picsum.photos/seed/barrel/215/215",
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
FranciscoG
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured this out by using
useState
within the story component