-
-
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
Use store revisions to ensure that stories re-render on HMR. #2588
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2588 +/- ##
==========================================
- Coverage 32.68% 32.67% -0.02%
==========================================
Files 398 398
Lines 8838 8842 +4
Branches 945 943 -2
==========================================
Hits 2889 2889
+ Misses 5305 5297 -8
- Partials 644 656 +12
Continue to review full report at Codecov.
|
Should we do the same for other apps? |
They don’t have this immediate problem. We’ll get this revision code in all
apps when we land the general story store PR
…On Thu, 28 Dec 2017 at 12:26 pm, Filipp Riabchun ***@***.***> wrote:
Should we do the same for other apps?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2588 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIFystmGsXL00rZMHgk6HRqihGWt1mTks5tEu47gaJpZM4RN6Q1>
.
|
Why do they need the revisions then? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a decent enough patch. also curious as to why the other two platforms don't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Have confirmed the bug and the fix on my machine, but don't understand the broader implications of this change (if any).
Good question, perhaps we can discuss elsewhere (I'll make this into a PR against #2241 and we can go into detail there). I think it is conceptually correct that we keep track in the storystore that the stories have changed; ie the output of In this case, such a distinction is needed because our React code is trying to avoid unnecessary re-renders when the story choice hasn't changed. There was no way (until this patch) for the React code to know if the story implementation had changed.
They don't need it immediately because they are not (AFAIK) making this optimization [I don't really know if they need to either]. This patch is a reaction to a bug introduced when I made this optimization in React in #2503. |
For #2587
Issue:
To avoid unnecessarily re-rendering stories we don't re-render if the story name+kind haven't changed.
However on HMR, this leads to not rerendering / breakage, as in this case the name/kind haven't changed, but the store's implementation itself changed.
What I did
I added the concept of a revision to the storystore. This implies that the same name+kind can be different as the store itself has changed. I got the idea from styleguidist which I think saw something similar in when I was reading their source ;)
Moving forward, if we want dynamic stores (yes please!) we may need to generalise the concept of revision to meaning more just "incrementing on each HMR".
How to test
Try changing stories implementations in the kitchen sink.
Is this testable with jest or storyshots? No
Does this need a new example in the kitchen sink apps? No
Does this need an update to the documentation? No
We should ensure this is merged into #2241