@samitouri / QOS-React-2 / commits / 1102fc5c11

Refactor: extract a variable

Dan Abramov committed Apr 10, 2019 at 15:25 UTC 1102fc5c1190b08ad5032333975ec57d9a0b5254
1 file changed +3 -2
src/devtools/views/Components/TreeContext.js
+3 -2
@@ -325,14 +325,15 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
325 didRequestSearch = true;
326 }
327 if (searchText !== prevSearchText) {
328 - if (searchResults.indexOf(selectedElementID) === -1) {
328 + const newSearchIndex = searchResults.indexOf(selectedElementID);
329 + if (newSearchIndex === -1) {
330 // Only move the selection if the new query
331 // doesn't match the current selection anymore.
332 didRequestSearch = true;
333 } else {
334 // Selected item still matches the new search query.
335 // Adjust the index to reflect its position in new results.
335 - searchIndex = searchResults.indexOf(selectedElementID);
336 + searchIndex = newSearchIndex;
337 }
338 }
339 if (didRequestSearch) {