【发布时间】:2021-09-04 10:21:27
【问题描述】:
【问题讨论】:
-
你应该提供你的代码。
标签: react-native react-native-flatlist
【问题讨论】:
标签: react-native react-native-flatlist
这是您想要的简单版本:
const sevenDaysAgo = Date.now() - 60 * 60 * 24 * 7 * 1000 // seven days ago in timestamp
const [data, setData] = useState(your Data);
const sevenLastDaysData = useMemo(() => {
return data.filter(item => item.date >= sevenDaysAgo);
// IMPORTANT: item.date Must be timpestamp other wise you should convert it to timestamp
}, [data]);
return (
<FlatList
data={sevenLastDaysData}
...
/>
)
【讨论】: