【发布时间】:2018-01-05 17:41:29
【问题描述】:
我正在为我的 React-Native 应用程序使用 React-Native-Router-Flux 来处理我的路线。在我的路线中,我在 MoreIcon 上有一个函数调用,它应该在 onPress 上运行,但除非我删除 Lambda 运算符,否则什么都不会执行,但它会在组件挂载时立即执行它。
我尝试返回而不返回从 onPress 调用的警报函数,但仍然没有运气。
{/* Live Feed Tab View */}
<routes.Scene key = "Live" title = "Live" icon={Icons.LiveIcon}>
<routes.Scene key="LiveFeed" component={LiveFeed} renderRightButton = {() => { return <MoreIcon onPress = { () => {return alert() } } />; }} renderTitle={() => { return <AppLogo />; }} />
<routes.Scene key="Profile" component={Profile} title="Profile" renderRightButton = {() => { return <MoreIcon />; }} />
<routes.Scene key="Reply" component={Reply} title="Replies" />
<routes.Scene key="Camera" component={Camera} title="Camera" />
<routes.Scene key="Preview" component={Preview} title="Preview" />
<routes.Scene key="MakePost" component={MakePost} title="MakePost" />
</routes.Scene>
【问题讨论】:
-
你能提供
MoreIcon的代码吗?
标签: javascript reactjs react-native react-native-router-flux