From 09bc182eb3506ee8d56d09883bcfa7084841d24a Mon Sep 17 00:00:00 2001 From: pigcan Date: Thu, 17 May 2018 18:08:05 +0800 Subject: [PATCH 1/4] bugfix: fix react-lifecycles-compat usage --- source/ArrowKeyStepper/ArrowKeyStepper.js | 2 +- source/Collection/CollectionView.js | 2 +- source/Grid/Grid.js | 2 +- source/Masonry/Masonry.js | 2 +- source/MultiGrid/MultiGrid.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/ArrowKeyStepper/ArrowKeyStepper.js b/source/ArrowKeyStepper/ArrowKeyStepper.js index 5efe46cdc..67483ec0b 100644 --- a/source/ArrowKeyStepper/ArrowKeyStepper.js +++ b/source/ArrowKeyStepper/ArrowKeyStepper.js @@ -4,7 +4,7 @@ import type {RenderedSection} from '../Grid'; import type {ScrollIndices} from './types'; import * as React from 'react'; -import polyfill from 'react-lifecycles-compat'; +import { polyfill } from 'react-lifecycles-compat'; /** * This HOC decorates a virtualized component and responds to arrow-key events by scrolling one row or column at a time. diff --git a/source/Collection/CollectionView.js b/source/Collection/CollectionView.js index 78b1b681c..5c47962d9 100644 --- a/source/Collection/CollectionView.js +++ b/source/Collection/CollectionView.js @@ -2,7 +2,7 @@ import cn from 'classnames'; import PropTypes from 'prop-types'; import * as React from 'react'; -import polyfill from 'react-lifecycles-compat'; +import { polyfill } from 'react-lifecycles-compat'; import createCallbackMemoizer from '../utils/createCallbackMemoizer'; import getScrollbarSize from 'dom-helpers/util/scrollbarSize'; diff --git a/source/Grid/Grid.js b/source/Grid/Grid.js index f1a17ea5e..4d644d28c 100644 --- a/source/Grid/Grid.js +++ b/source/Grid/Grid.js @@ -29,7 +29,7 @@ import defaultOverscanIndicesGetter, { import updateScrollIndexHelper from './utils/updateScrollIndexHelper'; import defaultCellRangeRenderer from './defaultCellRangeRenderer'; import scrollbarSize from 'dom-helpers/util/scrollbarSize'; -import polyfill from 'react-lifecycles-compat'; +import { polyfill } from 'react-lifecycles-compat'; import { requestAnimationTimeout, cancelAnimationTimeout, diff --git a/source/Masonry/Masonry.js b/source/Masonry/Masonry.js index c857c1695..e93820ea3 100644 --- a/source/Masonry/Masonry.js +++ b/source/Masonry/Masonry.js @@ -1,7 +1,7 @@ /** @flow */ import cn from 'classnames'; import * as React from 'react'; -import polyfill from 'react-lifecycles-compat'; +import { polyfill } from 'react-lifecycles-compat'; import PositionCache from './PositionCache'; import { requestAnimationTimeout, diff --git a/source/MultiGrid/MultiGrid.js b/source/MultiGrid/MultiGrid.js index dbc50e45e..311f2b6fa 100644 --- a/source/MultiGrid/MultiGrid.js +++ b/source/MultiGrid/MultiGrid.js @@ -1,7 +1,7 @@ /** @flow */ import PropTypes from 'prop-types'; import * as React from 'react'; -import polyfill from 'react-lifecycles-compat'; +import { polyfill } from 'react-lifecycles-compat'; import CellMeasurerCacheDecorator from './CellMeasurerCacheDecorator'; import Grid from '../Grid'; From a2901ce391be856e36d4a3f53786b449a26fb769 Mon Sep 17 00:00:00 2001 From: pigcan Date: Fri, 18 May 2018 10:39:42 +0800 Subject: [PATCH 2/4] fix: eslint errors --- source/ArrowKeyStepper/ArrowKeyStepper.js | 2 +- source/Collection/CollectionView.js | 2 +- source/Grid/Grid.js | 2 +- source/Masonry/Masonry.js | 2 +- source/MultiGrid/MultiGrid.js | 2 +- source/ScrollSync/ScrollSync.example.js | 8 ++++++-- source/demo/Wizard/Generator.js | 12 +++++++++--- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/source/ArrowKeyStepper/ArrowKeyStepper.js b/source/ArrowKeyStepper/ArrowKeyStepper.js index 67483ec0b..f3f60a4fa 100644 --- a/source/ArrowKeyStepper/ArrowKeyStepper.js +++ b/source/ArrowKeyStepper/ArrowKeyStepper.js @@ -4,7 +4,7 @@ import type {RenderedSection} from '../Grid'; import type {ScrollIndices} from './types'; import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; +import {polyfill} from 'react-lifecycles-compat'; /** * This HOC decorates a virtualized component and responds to arrow-key events by scrolling one row or column at a time. diff --git a/source/Collection/CollectionView.js b/source/Collection/CollectionView.js index 5c47962d9..c004b9ca1 100644 --- a/source/Collection/CollectionView.js +++ b/source/Collection/CollectionView.js @@ -2,7 +2,7 @@ import cn from 'classnames'; import PropTypes from 'prop-types'; import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; +import {polyfill} from 'react-lifecycles-compat'; import createCallbackMemoizer from '../utils/createCallbackMemoizer'; import getScrollbarSize from 'dom-helpers/util/scrollbarSize'; diff --git a/source/Grid/Grid.js b/source/Grid/Grid.js index 4d644d28c..c5524131d 100644 --- a/source/Grid/Grid.js +++ b/source/Grid/Grid.js @@ -29,7 +29,7 @@ import defaultOverscanIndicesGetter, { import updateScrollIndexHelper from './utils/updateScrollIndexHelper'; import defaultCellRangeRenderer from './defaultCellRangeRenderer'; import scrollbarSize from 'dom-helpers/util/scrollbarSize'; -import { polyfill } from 'react-lifecycles-compat'; +import {polyfill} from 'react-lifecycles-compat'; import { requestAnimationTimeout, cancelAnimationTimeout, diff --git a/source/Masonry/Masonry.js b/source/Masonry/Masonry.js index e93820ea3..1b02c6ac5 100644 --- a/source/Masonry/Masonry.js +++ b/source/Masonry/Masonry.js @@ -1,7 +1,7 @@ /** @flow */ import cn from 'classnames'; import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; +import {polyfill} from 'react-lifecycles-compat'; import PositionCache from './PositionCache'; import { requestAnimationTimeout, diff --git a/source/MultiGrid/MultiGrid.js b/source/MultiGrid/MultiGrid.js index 311f2b6fa..4a1eb8e99 100644 --- a/source/MultiGrid/MultiGrid.js +++ b/source/MultiGrid/MultiGrid.js @@ -1,7 +1,7 @@ /** @flow */ import PropTypes from 'prop-types'; import * as React from 'react'; -import { polyfill } from 'react-lifecycles-compat'; +import {polyfill} from 'react-lifecycles-compat'; import CellMeasurerCacheDecorator from './CellMeasurerCacheDecorator'; import Grid from '../Grid'; diff --git a/source/ScrollSync/ScrollSync.example.js b/source/ScrollSync/ScrollSync.example.js index e63ba1433..6d9c53cce 100644 --- a/source/ScrollSync/ScrollSync.example.js +++ b/source/ScrollSync/ScrollSync.example.js @@ -236,8 +236,12 @@ export default class GridExample extends React.PureComponent { _renderLeftSideCell({columnIndex, key, rowIndex, style}) { const rowClass = rowIndex % 2 === 0 - ? columnIndex % 2 === 0 ? styles.evenRow : styles.oddRow - : columnIndex % 2 !== 0 ? styles.evenRow : styles.oddRow; + ? columnIndex % 2 === 0 + ? styles.evenRow + : styles.oddRow + : columnIndex % 2 !== 0 + ? styles.evenRow + : styles.oddRow; const classNames = cn(rowClass, styles.cell); return ( diff --git a/source/demo/Wizard/Generator.js b/source/demo/Wizard/Generator.js index ffd8dd1a3..9de38e656 100644 --- a/source/demo/Wizard/Generator.js +++ b/source/demo/Wizard/Generator.js @@ -35,14 +35,18 @@ export default function Generator({ if (baseComponent.columnWidthProp) { baseComponent.props[baseComponent.columnWidthProp] = hasMultipleColumns ? cellsHaveKnownWidth - ? cellsHaveUniformWidth ? 100 : '({ index }) => 100' + ? cellsHaveUniformWidth + ? 100 + : '({ index }) => 100' : 'getColumnWidth' : widthValue; } if (baseComponent.rowHeightProp) { baseComponent.props[baseComponent.rowHeightProp] = hasMultipleRows ? cellsHaveKnownHeight - ? cellsHaveUniformHeight ? 50 : '({ index }) => 50' + ? cellsHaveUniformHeight + ? 50 + : '({ index }) => 50' : 'getRowHeight' : heightValue; } @@ -54,7 +58,9 @@ export default function Generator({ } if (baseComponent.rowCountProp) { baseComponent.props[baseComponent.rowCountProp] = hasMultipleRows - ? hasMultipleColumns ? 'numRows' : 'collection.size' + ? hasMultipleColumns + ? 'numRows' + : 'collection.size' : '1'; } From 88ddc1b282f38da19e2ee043954e350e4ecba87d Mon Sep 17 00:00:00 2001 From: pigcan Date: Fri, 18 May 2018 10:41:59 +0800 Subject: [PATCH 3/4] deps: upgrade react-lifecycles-compat to 3.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51f97bf57..519810275 100644 --- a/package.json +++ b/package.json @@ -173,7 +173,7 @@ "dom-helpers": "^2.4.0 || ^3.0.0", "loose-envify": "^1.3.0", "prop-types": "^15.6.0", - "react-lifecycles-compat": "^1.0.2" + "react-lifecycles-compat": "^3.0.4" }, "peerDependencies": { "react": "^15.3.0 || ^16.0.0-alpha", From 5ba743d90a457f07e7e6b9c9b29a2cb90542e392 Mon Sep 17 00:00:00 2001 From: Wei-Wei Wu Date: Thu, 17 May 2018 22:10:01 -0700 Subject: [PATCH 4/4] fixing lint and updating lock file --- source/ScrollSync/ScrollSync.example.js | 8 ++------ source/demo/Wizard/Generator.js | 12 +++--------- yarn.lock | 6 +++--- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/source/ScrollSync/ScrollSync.example.js b/source/ScrollSync/ScrollSync.example.js index 6d9c53cce..e63ba1433 100644 --- a/source/ScrollSync/ScrollSync.example.js +++ b/source/ScrollSync/ScrollSync.example.js @@ -236,12 +236,8 @@ export default class GridExample extends React.PureComponent { _renderLeftSideCell({columnIndex, key, rowIndex, style}) { const rowClass = rowIndex % 2 === 0 - ? columnIndex % 2 === 0 - ? styles.evenRow - : styles.oddRow - : columnIndex % 2 !== 0 - ? styles.evenRow - : styles.oddRow; + ? columnIndex % 2 === 0 ? styles.evenRow : styles.oddRow + : columnIndex % 2 !== 0 ? styles.evenRow : styles.oddRow; const classNames = cn(rowClass, styles.cell); return ( diff --git a/source/demo/Wizard/Generator.js b/source/demo/Wizard/Generator.js index 9de38e656..ffd8dd1a3 100644 --- a/source/demo/Wizard/Generator.js +++ b/source/demo/Wizard/Generator.js @@ -35,18 +35,14 @@ export default function Generator({ if (baseComponent.columnWidthProp) { baseComponent.props[baseComponent.columnWidthProp] = hasMultipleColumns ? cellsHaveKnownWidth - ? cellsHaveUniformWidth - ? 100 - : '({ index }) => 100' + ? cellsHaveUniformWidth ? 100 : '({ index }) => 100' : 'getColumnWidth' : widthValue; } if (baseComponent.rowHeightProp) { baseComponent.props[baseComponent.rowHeightProp] = hasMultipleRows ? cellsHaveKnownHeight - ? cellsHaveUniformHeight - ? 50 - : '({ index }) => 50' + ? cellsHaveUniformHeight ? 50 : '({ index }) => 50' : 'getRowHeight' : heightValue; } @@ -58,9 +54,7 @@ export default function Generator({ } if (baseComponent.rowCountProp) { baseComponent.props[baseComponent.rowCountProp] = hasMultipleRows - ? hasMultipleColumns - ? 'numRows' - : 'collection.size' + ? hasMultipleColumns ? 'numRows' : 'collection.size' : '1'; } diff --git a/yarn.lock b/yarn.lock index 647d21ba3..d27103878 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6485,9 +6485,9 @@ react-dom@^16.2.0: object-assign "^4.1.1" prop-types "^15.6.0" -react-lifecycles-compat@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-1.0.2.tgz#551d8b1d156346e5fcf30ffac9b32ce3f78b8850" +react-lifecycles-compat@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" react-router-dom@^4.1.1: version "4.1.1"