react-native - React Native 使用导航类组件
问题描述
我正在使用一个类组件,我想从这里导航到另一个屏幕。但它说导航是未定义的。我查阅了文档,我意识到我需要使用userNavigation
This。但我不知道如何实际使用它。请有人帮忙
export default class ReduxScreen extends Component {
render() {
return (
<View>
<Button block style={{ marginHorizontal: 30, marginTop: 50 }} onPress={() => {
//I want to add the useNavigation here
}}>
<Text style={{ color: '#FFF' }}>Start</Text>
</Button>
</View>
)
}}
解决方案
<Link />
像打击一样使用
import { Link } from 'react-router-dom';
export default class ReduxScreen extends Component {
render() {
return (
<View>
<Button component={Link} to="some-where" block style={{ marginHorizontal: 30, marginTop: 50 }}
}}>
<Text style={{ color: '#FFF' }}>Start</Text>
</Button>
</View>
)
}}
推荐阅读
- rxjs - RxJs 如何完成内部 observable
- maven - maven-cucumber-reporting 插件未生成报告 - 没有任何反应
- android - 制作包含 YouTube 视频的 Android 应用付费的 Monetize Ads 是否合法
- python - Python:“ImportError:DLL 加载失败:找不到指定的模块。” 导入ffn时的问题(python的财务库)
- svg - 无法从 qtwebkit 5.4.2 上的文件 (*.svg) 加载 svg 图像 - WEC7-x86
- javascript - 如何在没有表单的情况下提交动态数据?
- django - django-rest 和 angular nginx 加载静态图像问题
- ruby - 为什么尚未安装依赖项 gem 时 gem build .gemspec 会成功
- javascript - 如何在 GTM 中样式更改时触发元素可见性
- vue.js - 如何在 vue.js 中的 v-model 上获取对象的属性而不是整个对象