You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
545 B

// After
class ExampleComponent extends React.Component {
// Initialize state in constructor,
// Or with a property initializer.
// highlight-range{1-4}
state = {
isScrollingDown: false,
lastRow: null,
};
7 years ago
// highlight-range{1-7}
static getDerivedStateFromProps(props, state) {
if (props.currentRow !== state.lastRow) {
return {
isScrollingDown: props.currentRow > state.lastRow,
lastRow: props.currentRow,
};
}
// Return null to indicate no change to state.
return null;
}
}