Skip to content

addon-controls - how do I update an arg from a function prop #12647

Answered by FranciscoG
FranciscoG asked this question in Help
Discussion options

You must be logged in to vote

I figured this out by using useState within the story component

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",
};

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jamesonhill
Comment options

Answer selected by FranciscoG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants