【问题标题】:How to implement React Inverted Infinite Scroll (Scroll up) *CodeSandBox included如何实现 React Inverted Infinite Scroll (Scroll up) *CodeSandBox 包括
【发布时间】:2022-01-16 17:03:13
【问题描述】:
【问题讨论】:
标签:
reactjs
react-native
ecmascript-6
web-applications
react-hooks
【解决方案1】:
使用 flexbox 反转列
const style = {
display: "flex",
flexDirection: 'column-reverse',
width: "100px",
height: "250px",
overflow: "auto",
border: "1px solid #000"
};
【解决方案2】:
只需在您的样式中添加以下代码:
const style = {
...,
display: "flex",
flexDirection: 'column-reverse'
};
我取消了您 useLayoutEffect
中的代码的注释
useLayoutEffect(() => {
bottomRef.current.scrollIntoView({ behavior: "smooth" });
}, [messages]);