reactjs - 在加载相同组件但具有不同数据的路由之间反应导航滑动
问题描述
我是反应导航的新手,但我正在尝试制作一个天气应用程序。我希望用户能够保存多个位置,并通过向右滑动切换到不同的位置。所以组件保持不变,但数据发生变化。
有谁知道我怎么能这样工作?我目前正在使用 StackNavigator,但我没有看到任何关于此的文档。(存储的整个位置我已经知道该怎么做,所以它只是关于滑动导航)
解决方案
import {Swipeable} from 'react-native-gesture-handler';
const Left=()=>{
//call a funcion
or
return // value after a call
};
const Right =() => {
return (
<View>
<Icon
name="trash-outline"
size={ms(28)}
color="black"
onPress={() => {
//call a function to change the data.
}}
/>
</View>
);
};
<Swipeable
renderRightActions={() => Right()}
renderLeftActions={() => Left()}>
//your component here
</Swipable>
您可以在组件上左右滑动,并在用户滑动时直接调用该函数或显示一个图标来调用该函数。
推荐阅读
- calendar - 使用 C++Builder 创建日历
- audio - 如何实时流式传输音频文件
- c# - 以有效方式从 XmlNode 读取/提取值的问题
- ios - 有没有办法准确检测用户在 Xcode 上使用的设备类型
- docker - 运行“docker-compose up”时出错:配置无效,异常退出
- javascript - 在调用每个函数时记录它的名称
- amazon-ec2 - 如何在 linux - redhat 7.4 重启后恢复 cfn-init 命令?
- github - 如何在 GitHub 上的代码审查中手动添加建议?
- python - Bokeh 如何根据 pandas 数据框制作带有错误的趋势线图?
- angular - TS2304:找不到名称“描述”或“预期”