From 55650fc12c6902826efcdccba076c45decb884c4 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 15 Mar 2018 08:48:01 -0700 Subject: [PATCH] Added explicit null value in state initializer --- .../updating-state-from-props-after.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/update-on-async-rendering/updating-state-from-props-after.js b/examples/update-on-async-rendering/updating-state-from-props-after.js index dc5eccde..fe5de411 100644 --- a/examples/update-on-async-rendering/updating-state-from-props-after.js +++ b/examples/update-on-async-rendering/updating-state-from-props-after.js @@ -2,18 +2,19 @@ class ExampleComponent extends React.Component { // Initialize state in constructor, // Or with a property initializer. - // highlight-range{1-3} + // highlight-range{1-4} state = { isScrollingDown: false, + lastRow: null, }; // highlight-line // highlight-range{1-8} static getDerivedStateFromProps(nextProps, prevState) { if (nextProps.currentRow !== prevState.lastRow) { return { - lastRow: nextProps.currentRow, isScrollingDown: nextProps.currentRow > prevState.lastRow, + lastRow: nextProps.currentRow, }; }