storybook-addon-actions icon indicating copy to clipboard operation
storybook-addon-actions copied to clipboard

decorateAction not working as expected

Open ritz078 opened this issue 8 years ago • 1 comments

So currently, if I do args => args.splice(0, 1) still I will get an array. How can I just log the first element of that array ?

if I do

const firstArg = decorateAction([
  args => args[0]
]);

In simpler terms how do I log firstTerm instead of [firstTerm] if my args was [firstTerm, secondTerm, thirdTerm]

ritz078 avatar Oct 07 '16 13:10 ritz078

Hi @ritz078

Action decorators taking an array of arguments as input and returning an array is intentional. It'll be easier to write action decorators this way.

For your case, try decorating the action manually

const firstArg = name => {
  const actionFn = action(name)
  return (...args) => actionFn(args[0])
}

thani-sh avatar Oct 10 '16 09:10 thani-sh