Conversation
| searchNetworks.push(networkName); | ||
| } | ||
|
|
||
| // Sets the new value for "searchNetworks" using a "Set" to *lazy* clean duplicates; who knows? |
There was a problem hiding this comment.
I like lodash and we have used it a lot elsewhere.
https://lodash.com/docs/4.17.15#uniq
| clearTimeout(searchDelayer); | ||
|
|
||
| // Sets the new search delayer and the new searc text value. | ||
| setSearchDelayer(setTimeout(value => setSearchText(value), process.env.REACT_APP_SEARCH_INPUT_TEXT_DELAYER, searchText)); |
There was a problem hiding this comment.
i don't know if this will work, there could be a race condition in here.
Have you considered something like
https://www.npmjs.com/package/debounce
There was a problem hiding this comment.
There shouldn't be a race condition with the variable use to cancel the previous setTimeout, unless something weird is done while React compiles. Also looked at the source of debounce and it's doing that same thing.
| type="checkbox" | ||
| checked={searchExchanges.includes(exchangeName)} | ||
| onChange={() => { | ||
| let filter; |
There was a problem hiding this comment.
this seems overly complicated for a potential future we might not have.
did you check if onChange passes an arg to the callback that can be used in liew of the toggle you are trying to set up?
Then you could do something like
onChange={(e)=>{
setSearchExchanges(searchExchanges=>({
{...searchExchanges,
[exchangeName]:e.target.checked
}
}))
}}
There was a problem hiding this comment.
this functional version of setState also avoids any possible race conditions; it can't get out of sync with the actual html element
No description provided.