|
@ -428,8 +428,8 @@ Here, we store the previous value of the `row` prop in a state variable so that |
|
|
|
|
|
|
|
|
```js |
|
|
```js |
|
|
function ScrollView({row}) { |
|
|
function ScrollView({row}) { |
|
|
let [isScrollingDown, setIsScrollingDown] = useState(false); |
|
|
const [isScrollingDown, setIsScrollingDown] = useState(false); |
|
|
let [prevRow, setPrevRow] = useState(null); |
|
|
const [prevRow, setPrevRow] = useState(null); |
|
|
|
|
|
|
|
|
if (row !== prevRow) { |
|
|
if (row !== prevRow) { |
|
|
// Row changed since last render. Update isScrollingDown. |
|
|
// Row changed since last render. Update isScrollingDown. |
|
@ -718,7 +718,7 @@ As a last resort, if you want something like `this` in a class, you can [use a r |
|
|
```js{2-6,10-11,16} |
|
|
```js{2-6,10-11,16} |
|
|
function Example(props) { |
|
|
function Example(props) { |
|
|
// Keep latest props in a ref. |
|
|
// Keep latest props in a ref. |
|
|
let latestProps = useRef(props); |
|
|
const latestProps = useRef(props); |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
latestProps.current = props; |
|
|
latestProps.current = props; |
|
|
}); |
|
|
}); |
|
|