question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addons-actions: option to return something

See original GitHub issue

Is your feature request related to a problem? Please describe.

We have stories with callbacks that should return Promise.

storiesOf('Some Form', module).add('Default', () => (
  <Form initialValues={{}} onSubmit={action('Submit')} />
));

Form onSubmit prop: onSubmit: Promise<void>;

Describe the solution you’d like Option to specify a return value, either with a function or directly the value we want to return ?

storiesOf('Some Form', module).add('Default', () => (
  <Form initialValues={{}} onSubmit={action('Submit', { returnValue: Promise.resolve() )} />
));
storiesOf('Some Form', module).add('Default', () => (
  <Form initialValues={{}} onSubmit={action('Submit', { getReturnValue: (values) => Promise.resolve() )} />
));

I’m not sure about the naming

Describe alternatives you’ve considered

Allowing onSubmit return type to accept void.

Are you able to assist bring the feature to reality? yes, I can open a PR if it’s accepted

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
jonfreedmancommented, Oct 15, 2021

I don’t think these workarounds work with the new actions approach (e.g. ‘action’ is not imported) - just hit this exact issue myself.

3reactions
iamxyzbycommented, Mar 8, 2021

You can try this:

const promiseAction = (msg) => (...args) => {
    action(msg)(...args)
    return Promise.resolve()
}

storiesOf('Some Form', module).add('Default', () => (
  <Form initialValues={{}} onSubmit={promiseAction('Submit1')} />
));

storiesOf('Some Form', module).add('Default', () => (
  <Form initialValues={{}} onSubmit={promiseAction('Other Submit')} />
));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Return Items You Ordered - Amazon Customer Service
Choose the order and select Return or Replace Items. Select the item you want to return. Then select an option from the Reason...
Read more >
Returning items you bought from Microsoft Store for exchange ...
Learn how to receive a Microsoft refund or exchange for items purchased or unexpected charges from ... Refunds are applied to the original...
Read more >
Amazon offers free returns with no box, tape, or label needed
Amazon makes returns even easier with thousands of free drop off options for millions of items. Our goal at Amazon is to make...
Read more >
Process a Return or Exchange with Square for Retail
With Square for Retail Plus, you will have the option to either process a ... With Square for Retail, you can process a...
Read more >
Return an item - Google Store Help
You can return most items you bought from the Google Store within 15 calendar days after the day you receive it. Returns are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found