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.
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
[Fix #269] use cached data #280
[Fix #269] use cached data #280
Changes from 42 commits
1998ca0
09b9494
0f5e115
98a1672
916b9b0
35becc3
4b7f267
6943d36
790def1
f71294e
9358b41
3ee9294
fcc49ac
853390e
0c72be1
294aa31
d2a5390
5b00715
8a3bc95
bf48eb3
fbc16fc
48570e8
68c3d04
937c3f7
cb505e3
46f73e1
a2e20d0
617ff64
5ffdefa
2c45edb
d479c12
020ccb2
0756a27
7904d58
c7ac445
127f56c
9a4135f
9a41243
cdb9e82
1caf3f9
ad4758d
e531270
69fac60
ff82a94
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.
I am not sure why do we set the tempState to the same cachedState as the normal state. I might be missing something but could you help me understand this? Should we update the comment above?
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.
The intention here is that
tempState
is still used in the same way as it was before.If we did not get all the values from the cache then the values are held in the
tempState
until all are "loaded". This way we avoid callingsetState()
each time a value comes back from storage. That was the original optimization added here and is a good thing because otherwise you may have like several calls to setState() happening in a kind of burst before the first render (at least that's what we saw and why we changed how this works).Though the question did make me wonder about something... if
this.tempState
andthis.state
are initialized with the same object reference then will we be mutating the state directly on this line:react-native-onyx/lib/withOnyx.js
Line 117 in 80c6f00
Seems like that would be undesirable in the case where you did not initialize all the values in the constructor.
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.
Thanks for the write up. @hannojg what do you think of the concern Marc raised above?