-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap componentWillReceiveProps in setTimeout
We're seeing an issue where the props that we pass also change when the value in the input-field does. This causes two problems 1) selectedItems gets overwritten again even though we've not changed the default selected account. This can be avoided by comparing the prop to see if it's actually changed. The react docs for componentWillReceiveProps also state that it may be called even if the props haven't changed and that checking for changes is a good idea in the first place. 2) Since the component is reading the inputValue from state, there's a chance it will get the previous value if setState was called from onInputChange in the same cycle of the event loop because setState is asynchronous. This is solved by wrapping the code in setTimeout, forcing it to run after we're sure the state has been settled. There might be a Better Way to do this but I'm not really up to the task right now.
- Loading branch information
Showing
3 changed files
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters