Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typeof function instead of instanceof Function #596

Merged
merged 1 commit into from
Feb 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ export default class Grid extends PureComponent {
}

_wrapPropertyGetter (value) {
return value instanceof Function
return typeof value === 'function'
? value
: () => value
}
Expand Down
8 changes: 4 additions & 4 deletions source/MultiGrid/MultiGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default class MultiGrid extends PureComponent {
_columnWidthRightGrid ({ index }) {
const { fixedColumnCount, columnWidth } = this.props

return columnWidth instanceof Function
return typeof columnWidth === 'function'
? columnWidth({ index: index + fixedColumnCount })
: columnWidth
}
Expand All @@ -223,7 +223,7 @@ export default class MultiGrid extends PureComponent {
const { fixedColumnCount, columnWidth } = props

if (this._leftGridWidth == null) {
if (columnWidth instanceof Function) {
if (typeof columnWidth === 'function') {
let leftGridWidth = 0

for (let index = 0; index < fixedColumnCount; index++) {
Expand Down Expand Up @@ -251,7 +251,7 @@ export default class MultiGrid extends PureComponent {
const { fixedRowCount, rowHeight } = props

if (this._topGridHeight == null) {
if (rowHeight instanceof Function) {
if (typeof rowHeight === 'function') {
let topGridHeight = 0

for (let index = 0; index < fixedRowCount; index++) {
Expand Down Expand Up @@ -516,7 +516,7 @@ export default class MultiGrid extends PureComponent {
_rowHeightBottomGrid ({ index }) {
const { fixedRowCount, rowHeight } = this.props

return rowHeight instanceof Function
return typeof rowHeight === 'function'
? rowHeight({ index: index + fixedRowCount })
: rowHeight
}
Expand Down
10 changes: 5 additions & 5 deletions source/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export default class Table extends PureComponent {

const availableRowsHeight = disableHeader ? height : height - headerHeight

const rowClass = rowClassName instanceof Function ? rowClassName({ index: -1 }) : rowClassName
const rowStyleObject = rowStyle instanceof Function ? rowStyle({ index: -1 }) : rowStyle
const rowClass = typeof rowClassName === 'function' ? rowClassName({ index: -1 }) : rowClassName
const rowStyleObject = typeof rowStyle === 'function' ? rowStyle({ index: -1 }) : rowStyle

// Precompute and cache column styles before rendering rows and columns to speed things up
this._cachedColumnStyles = []
Expand Down Expand Up @@ -456,8 +456,8 @@ export default class Table extends PureComponent {

const { scrollbarWidth } = this.state

const rowClass = rowClassName instanceof Function ? rowClassName({ index }) : rowClassName
const rowStyleObject = rowStyle instanceof Function ? rowStyle({ index }) : rowStyle
const rowClass = typeof rowClassName === 'function' ? rowClassName({ index }) : rowClassName
const rowStyleObject = typeof rowStyle === 'function' ? rowStyle({ index }) : rowStyle
const rowData = rowGetter({ index })

const columns = React.Children.toArray(children).map(
Expand Down Expand Up @@ -532,7 +532,7 @@ export default class Table extends PureComponent {
_getRowHeight (rowIndex) {
const { rowHeight } = this.props

return rowHeight instanceof Function
return typeof rowHeight === 'function'
? rowHeight({ index: rowIndex })
: rowHeight
}
Expand Down
2 changes: 1 addition & 1 deletion source/Table/defaultCellDataGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function defaultCellDataGetter ({
dataKey,
rowData
}: CellDataGetterParams) {
if (rowData.get instanceof Function) {
if (typeof rowData.get === 'function') {
return rowData.get(dataKey)
} else {
return rowData[dataKey]
Expand Down
2 changes: 1 addition & 1 deletion source/utils/initCellMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function initCellMetadata ({
cellCount,
size
}) {
const sizeGetter = size instanceof Function
const sizeGetter = typeof size === 'function'
? size
: ({ index }) => size

Expand Down