今天,我读到Hoc(高阶组件)可以进行渲染劫持,所以如果有人知道这个概念,我想知道什么是渲染劫持,请在此处分享。
我在简单的屏幕底部添加了按钮,每当按下按钮时我都想滚动顶部.什么代码添加到按钮onPress?,请建议任何解决方案,提前谢谢.
我已在简单屏幕上添加了按钮,每当按下按钮时我想滚动底部。向按钮 onPress 添加什么代码?
render() {
return (
<ScrollView>
{this.yourComponents()}
<Button>Scroll To Bottom </Button>
</ScrollView>
)
}
Run Code Online (Sandbox Code Playgroud) constructor(props) {
super(props);
let comments = [{body: "good", created_at:"2018-02-12T05:27:47.175Z"},
{body: "bad article", created_at:"2017-11-12T05:27:47.175Z"},
{body: "great", created_at:"2017-10-12T05:27:47.175Z"}];
this.state = { comments };
render() {
return(
{ comments.map((comment, index) =>
<Text>{comment.body}</Text>
)}
);
};
Run Code Online (Sandbox Code Playgroud)
数据按降序排列,但我想根据created_at日期按升序排序.
现在,新的评论首先出现,并且想要先老的评语.
我该如何对此评论进行排序?请建议任何解决方案.
react-native ×4
button ×2
onpress ×2
reactjs ×2
javascript ×1
mapping ×1
scroll ×1
scrollview ×1
sorting ×1