-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async/Await #489
Comments
@philcockfield Hope you are using the latest Storybook. I'll dig into this. |
@arunoda - |
I'll bump to latest |
BTW: 2.5.2 was what was in my package.json - but I was actually on 2.15.1 |
Confirmed - errors in the way described on |
I tried it's works pretty fine for me. Here's the code I used: const delayed = new Promise((resolve) => {
setTimeout(() => {
resolve('Hello');
}, 2000);
});
async function kk() {
console.log('Begin Printing');
const data = await delayed;
console.log(data);
console.log('End Printing');
}
kk(); I tried in both NPM 2 and NPM 3. Could you send me some sample code and I'll try to dig into where this goes wrong? |
@arunoda - weird, I've just tried your code and it works fine here too - so I've got something else strange happening in the pipeline. Thanks for checking it out, and sorry for the false alarm. |
I'm using the latest storybook (2.24.0) and am still getting this issue using redux-sagas and generators. I've done both what @philcockfield did by trying to import the babel-polyfill (as well as setting the webpack entry point for it), as well as what @arunoda said where it should just work with the latest storybook out-the-box. |
Similar issue here. I'm on 2.29.3 and have tried using I've tried troubleshooting it on my own a little and could see the regenerator-runtime module adding @philcockfield, did you ever figure out what was throwing the error for you? @arunoda any other suggestions on what I might be able to try? |
@kgoggin I solved a very similar issue just now (regeneratorRuntime was expected in the global scope by |
@nicolasartman Your solution works only for hot-reloading, I tried to reload a page after that and the error |
Same issue here, I'm using generators in a Component and I run into this issue. Did what @nicolasartman suggested and it worked. Good for a quick fix. Didn't get the problem @isomoar had. |
to fix // .storybook/.babelrc
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
], |
|
polyfill has been added |
I still have the same problem with Storybook 4 and Babel 7. I'm not sure what I'm missing here. I'm using redux-sagas which requires generators. The default polyfill wasn't there I think and adding it explicitly with custom babelrc didn't work. |
@pouyas-github Add |
Just like @pouyas-github I was having issues with Storybook 4 and Babel 7. It turned out using async/await in a story worked fine, the actual problem was due to a plugin ( To fix this, I had to tweak Storybook's module.exports = {
module: {
rules: [
{
test: /\.stories\.js?$/,
loader: require.resolve('@storybook/addon-storysource/loader'),
options: {
prettierConfig: {
parser: 'babel' // needed for async/await in stories
}
},
enforce: 'pre',
},
...
}
} |
I'm using a vanilla setup of StoryBook with no tweaks to babel. If I use
async/await
I get an error of:Typically the
babel-polyfill
is required to have async/await work on the client. What are the steps to get this working within StoryBook?I tried importing
babel-polyfill
within the.storybook/config.js
but to no avail.Thanks.
The text was updated successfully, but these errors were encountered: