Skip to content
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

Preview hooks: trigger effects after story render #7791

Merged
merged 4 commits into from
Aug 19, 2019

Conversation

Hypnosphi
Copy link
Member

@Hypnosphi Hypnosphi commented Aug 17, 2019

Issue: #7786 (comment) doesn't work because the effects are triggered too early, before the story is rendered

This also addresses #7407 (comment)

@vercel
Copy link

vercel bot commented Aug 17, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

@Hypnosphi Hypnosphi requested a review from shilman August 17, 2019 14:18
@vercel vercel bot temporarily deployed to staging August 17, 2019 15:18 Inactive
@Hypnosphi Hypnosphi force-pushed the trigger-effects-after-render branch from 12a30c7 to 149ceba Compare August 17, 2019 15:25
@vercel vercel bot temporarily deployed to staging August 17, 2019 15:25 Inactive
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions inline

@@ -226,8 +226,10 @@ export default function start(render, { decorateStory } = {}) {
case 'story':
default: {
if (getDecorated) {
render(renderContext);
addons.getChannel().emit(Events.STORY_RENDERED, id);
(async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to catch here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the handler? logger.error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find a way to pass error callback to ReactDOM.render which is the only source of asynchrony here.

Looks like they just use then without catch: https://github.com/facebook/react/blob/master/packages/react-dom/src/client/ReactDOM.js#L393
So we won't actually catch anything. Hopefully, that means that React does the error handling for us

app/react/src/client/preview/render.tsx Show resolved Hide resolved
@shilman shilman merged commit bc8250f into next Aug 19, 2019
@shilman shilman deleted the trigger-effects-after-render branch August 19, 2019 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants