@lessondesk/react-table-context
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -62,10 +62,8 @@ var React = require('react'); | ||
var compareRows = function compareRows(array1, array2, rowFormatter) { | ||
var compareRows = function compareRows(array1, array2, getRowIdentifier) { | ||
if (array1.length !== array2.length) return false; | ||
return array1.every(function (row) { | ||
var _rowFormatter = rowFormatter(row), | ||
key = _rowFormatter.key; | ||
var key = getRowIdentifier(row); | ||
return array2.some(function (row2) { | ||
return key === rowFormatter(row2).key; | ||
return key === getRowIdentifier(row2); | ||
}); | ||
@@ -345,4 +343,8 @@ }); | ||
autoApplyFilters = _this$props2.autoApplyFilters, | ||
rowFormatter = _this$props2.rowFormatter; | ||
var isSame = compareRows(selected, previous == null ? void 0 : previous.selected, rowFormatter) && compareRows(expanded, previous == null ? void 0 : previous.expanded, rowFormatter); | ||
_this$props2$getRowId = _this$props2.getRowIdentifier, | ||
getRowIdentifier = _this$props2$getRowId === void 0 ? function (_ref4) { | ||
var id = _ref4.id; | ||
return id; | ||
} : _this$props2$getRowId; | ||
var isSame = compareRows(selected, previous == null ? void 0 : previous.selected, getRowIdentifier) && compareRows(expanded, previous == null ? void 0 : previous.expanded, getRowIdentifier); | ||
if (!isSame) this.setState({ | ||
@@ -349,0 +351,0 @@ selected: selected, |
{ | ||
"name": "@lessondesk/react-table-context", | ||
"description": "Flexible Table Provider & Consumer", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"main": "dist/react-table-context.js", | ||
@@ -6,0 +6,0 @@ "source": "src/index.js", |
@@ -8,7 +8,7 @@ import React, { createContext, Component } from 'react' | ||
const compareRows = (array1, array2, rowFormatter) => { | ||
const compareRows = (array1, array2, getRowIdentifier) => { | ||
if (array1.length !== array2.length) return false | ||
return array1.every(row => { | ||
const { key } = rowFormatter(row) | ||
return array2.some(row2 => key === rowFormatter(row2).key) | ||
const key = getRowIdentifier(row) | ||
return array2.some(row2 => key === getRowIdentifier(row2)) | ||
}) | ||
@@ -60,5 +60,11 @@ } | ||
componentDidUpdate(previous) { | ||
const { selected, expanded, filters, autoApplyFilters, rowFormatter } = this.props | ||
const isSame = compareRows(selected, previous?.selected, rowFormatter) && | ||
compareRows(expanded, previous?.expanded, rowFormatter) | ||
const { | ||
selected, | ||
expanded, | ||
filters, | ||
autoApplyFilters, | ||
getRowIdentifier = ({ id }) => id | ||
} = this.props | ||
const isSame = compareRows(selected, previous?.selected, getRowIdentifier) && | ||
compareRows(expanded, previous?.expanded, getRowIdentifier) | ||
@@ -65,0 +71,0 @@ if (!isSame) this.setState({ selected, expanded }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44354
642