This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make Store component more robust #792
Make Store component more robust #792
Changes from 5 commits
be2f01f
5b0b5de
18af043
c3e0493
2b2d6fa
d771fc7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
test_stcp003_initial_falsy
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.
I bet this would all be even simpler if we moved to a functional component with
useEffect
, but anyway this is the key point allowing you to re-supply the same component with nodata
and have the old value persist.If you actually remove it completely and bring it back later, it already worked, via the
UNSAFE_componentWillMount
pathway. This is only if the component is already on the page and you provide it again - ie as part of a largerchildren
prop in which some other things may have changed.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.
Running this against a modified version of https://dash.plotly.com/dash-core-components/store, I expected to be able to rename the
dcc.Store
component in there for ones that were unique to this layout and everything work 👌Turns out the callback triggered by https://github.com/plotly/dash-docs/blob/master/dash_docs/chapters/dash_core_components/Store/examples/store_clicks.py#L74 is not triggered on load, resulting in all field having value
0
. On click, they are updated toprevious+1
as expected.Possibly outside the scope of this PR, but a close neighbour.
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.
Can you post the exact app you're using? The app seems to behave correctly when I try 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.
Running from the docs entry point
index.py
:Prior to changes,
0
. Click the buttons to update and see that the callbacks work.0
Here's the modified code for
store_clicks.py
# no-exec
commentsnew-[memory|session|local]
0
. Click the buttons to update and see that the callbacks work.0
again0
toprevious+1
Running this against latest of
dash@dev
.Running
store_clicks.py
directly, not from inside the entire docs app, the behavior is as expected.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.
got it, thanks! Investigating... Here's a standalone version that shows the bug, just wrapping the layout in a content callback:
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.
Ha, this is actually yet another renderer bug... PR coming in Dash as soon as I figure out how to write a test for 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.
Fixed in plotly/dash#1224
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.
https://github.com/plotly/dash-docs/pull/871 shows that between this PR and plotly/dash#1224 there are no issues anymore running the store examples unmodified within the docs.