From 025dd41c833a421a0981c23fea92e478a4435323 Mon Sep 17 00:00:00 2001 From: Hugh Date: Fri, 8 Nov 2019 13:09:18 +0000 Subject: [PATCH 1/2] Mark componentWillReceiveProps UNSAFE This is the minimum change required for React 17 compatibility. The warning thrown by React 16, for reference: ``` Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details. * Move data fetching code or side effects to componentDidUpdate. * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state * Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder. ``` --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index adbdba4..28d2dd0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -170,7 +170,7 @@ export default class VirtualList extends React.PureComponent { } } - componentWillReceiveProps(nextProps: Props) { + UNSAFE_componentWillReceiveProps(nextProps: Props) { const { estimatedItemSize, itemCount, From 7a02d68990ce6b4ba956c8d4a3b6536aa20d3bf9 Mon Sep 17 00:00:00 2001 From: Hugh Date: Wed, 4 Dec 2019 13:24:11 +0000 Subject: [PATCH 2/2] Eslint should ignore this non_camelCase name It's named that way because it's a hack, but it needs to get past Travis. --- src/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.tsx b/src/index.tsx index 28d2dd0..d45a611 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -170,6 +170,7 @@ export default class VirtualList extends React.PureComponent { } } + // eslint-disable-next-line camelcase UNSAFE_componentWillReceiveProps(nextProps: Props) { const { estimatedItemSize,