使用React-Navigation从React-Native/Redux中的详细视图中删除

使用React-Navigation从React-Native/Redux中的详细视图中删除,react-native,redux,react-navigation,React Native,Redux,React Navigation,我正在使用Redux和React导航构建React本机应用程序。我不知道如何从它自己的视图中删除项目。它的布局非常简单: 级别1:索引-所有项目的列表 级别2:详细视图-详细传递项目的id,然后从地图状态获取适当的数据到道具 在详细视图中,我需要包含一个“删除”按钮,但是当我更新状态(当然是不变的)时,它仍在查看详细视图,并抛出许多错误,因为包含数据的数组元素根本不再处于该状态 My Index.js render render () { const { navigate } = thi

我正在使用Redux和React导航构建React本机应用程序。我不知道如何从它自己的视图中删除项目。它的布局非常简单:

  • 级别1:索引-所有项目的列表
  • 级别2:详细视图-详细传递项目的id,然后从地图状态获取适当的数据到道具
在详细视图中,我需要包含一个“删除”按钮,但是当我更新状态(当然是不变的)时,它仍在查看详细视图,并抛出许多错误,因为包含数据的数组元素根本不再处于该状态

My Index.js render

render () {
  const { navigate } = this.props.navigation
  return (
    <View style={{flex: 1}}>
    <List>
      {
        this.props.inbox.map((el) => {
          return (
            <ListItem
              key={el.ownerId}
              title={el.owner}
              onPress={ () => navigate('MessageView', { ownerId: el.ownerId, ownerName: el.owner }) }
            />
          )
       })
     }
 ...
const mapStateToProps = (state) => {
  return {
    inbox: state.inboxReducer.inbox
  }
}

您提供的代码似乎不相关<代码>队列,
排队消息
只发生在一个地方。
queued_msg
如何传入?
  _deleteMessage () {
    this.props.navigation.goBack()
    this.props.deleteMessage(this.props.queued_msg._id)
  }
...
render(){
   <Button
      backgroundColor='#E81E63'
      title="Login"
      onPress={this._deleteMessage.bind(this)}
      buttonStyle={styles.button}
      title='Delete Message' />
}
queue: [
    {
      _id: 1,
      owner: 'John Lennon',
      owner_id: 1,
      walker: 'Sally Sue',
      scheduled_for: new Date(),
      walker_id: 1,
      message: 'Rex peed and pooped.',
      logged_at: new Date()
    }
...]