-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep old reference in the state if they have not changed (#2114)
* Keep old references in the tableData * Make update function more compact
- Loading branch information
Showing
3 changed files
with
40 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
import isEqual from 'lodash.isequal' | ||
import { BaseType } from './objects' | ||
|
||
export const pushIf = <T>(array: T[], condition: boolean, elements: T[]) => | ||
condition && array.push(...elements) | ||
|
||
export const keepEqualOldReferencesInArray = ( | ||
oldArray: BaseType[], | ||
newArray: BaseType[] | ||
) => | ||
newArray.map(item => oldArray.find(oldItem => isEqual(oldItem, item)) || item) |
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