我有这个屏幕NewsTabScreen.js
class NewsTabScreen extends Component {
render() {
const { navigate } = this.props.navigation;
return (
<Container style={style.container}>
<Tabs renderTabBar={() => <ScrollableTab tabsContainerStyle={{backgroundColor: Platform.OS == 'ios' ? '#F8F8F8' : '#3F51B5'}}/>}>
<Tab heading={
<TabHeading>
<Text style={{ fontSize: 14 }}>{I18n.t("news")}</Text>
</TabHeading>}>
<News/>
</Tab>
<Tab heading={
<TabHeading>
<Text style={{ fontSize: 14 }}>{I18n.t("newsOfCommittees")}</Text>
</TabHeading>}>
<ComNews/>
</Tab>
<Tab heading={
<TabHeading>
<Text style={{ fontSize: 14 }}>{I18n.t("requests")}</Text>
</TabHeading>}>
<RequestsNews/>
</Tab>
</Tabs>
</Container>
);}}
当我点击新闻上的项目时,我收到错误
无法读取undefined
的属性'navigate'
答案 0 :(得分:0)
如果News
组件不属于任何导航器,但您仍想访问withNavigation
,则需要将navigation
组件与class News extends React.Component {
...
}
export default withNavigation(News);
一起打包,请查看文档here < / p>
像
<form method="POST" action="{{url('submit', [$id])}}">
{{ csrf_field() }}
<button type="submit">Submit</button>
</form>
希望这会有所帮助!