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.

How to write story that updates component?

See original GitHub issue

I would like to simply see if component behaves correctly when it receives new props. Or even if it receives same props so it’s possible to check that there is no logical error with shouldComponentUpdate. Is there some way for that?

Perhaps an idea for addon? Although I see tiny problem with addons that they cannot be combined, so if such functionality comes with addon, I could not use info addon for that story.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
arunodacommented, Jul 20, 2016

componentWillUpdate is not called in the initial render. We always do the initial rendering for all stories. That to prevent to state related issues.

So, if you wanna test componentWillUpdate you need to run render your component inside a wrapper component.

That wrapper component may have a some kind of a button which re-render your original component. Then it’ll call the componentWillUpdate.

0reactions
danielkczcommented, Sep 15, 2016

Ah, sorry, I wanted to try it first before responding, but never got a chance with it (more priority stuff). But what you said makes total sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write stories - Storybook - JS.ORG
We define stories according to the Component Story Format (CSF), an ES6 module-based standard that is easy to write and portable between tools....
Read more >
How to write story that updates component? #315 - GitHub
Component will get updated when location is retrieved. I can write story for a first case, but I am failing with other one....
Read more >
How to write an 'Update me' article - Smartocto
Be sure to state the facts, answering the who, what, why, where and when questions.
Read more >
What is Storybook and How Can I Use It to Create a ...
Once you build out a component, Storybook lets you create a "story" file where you can then import your component and create various...
Read more >
Storybook understanding and ways writing of Stories for React
The component we create is called the story in Storybook. In this article, we will understand the following topics: How to write a...
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