React native 从嵌套在onPress上的渲染行上的列表项访问状态函数

React native 从嵌套在onPress上的渲染行上的列表项访问状态函数,react-native,react-router,react-redux,React Native,React Router,React Redux,我试图从my rowonPress功能中访问我的一个操作,但问题出在onPress中,它超出了状态其余部分的范围 我的问题是如何从我的onPress方法中访问要调用的状态函数 import {planLocalesFetch, localeDelete} from '../actions'; import LocaleListItem from './LocaleListItem'; import Swipeout from 'react-native-swipeout'; class Pl

我试图从my row
onPress
功能中访问我的一个操作,但问题出在
onPress
中,它超出了状态其余部分的范围

我的问题是如何从我的
onPress
方法中访问要调用的状态函数

import {planLocalesFetch, localeDelete} from '../actions';
import LocaleListItem from './LocaleListItem';
import Swipeout from 'react-native-swipeout';

class  PlanLocalesList extends Component {

            // all the state code is here 

             renderRow(planLocale) {

              let swipeBtns = [{
                text: 'Delete',
                fontWeight: 'bold',
                backgroundColor: 'red',
                onPress: () => {
               axios.delete(`http://localhost:3000/locales/${planLocale.id}`, { params: {
                locale_id: planLocale.id }});
                this.props.planLocalesFetch(plan); // error is that this does not exist in this scope;
              }
              }];
              return (
                <Swipeout right={swipeBtns}
                  backgroundColor= 'transparent'>

                    <View>
                     <LocaleListItem planLocale={planLocale} />
                    </View>
                </Swipeout>
              )
            }

            render () {
              return (

                <View style={{flex: 1}}>
                  <ListView
                    dataSource={this.dataSource}
                    renderRow={this.renderRow.bind(this)}
                />
                </View>

              );
            }
          }

const mapStateToProps = state => {
const plan = state.planLocales.plan
const planLocales = _.map(state.planLocales.locales, (val, uid) => {
              return { ...val, uid };
            });
            return { planLocales, plan};
          };
export default  connect(mapStateToProps, {planLocalesFetch, localeDelete})(PlanLocalesList);

我遇到的问题是
this.props.planLocalesFetch(plan)不存在于嵌套的
onPress
范围中。

使用.then语句修复

let swipeBtns = [{
  text: 'Delete',
  fontWeight: 'bold',
  backgroundColor: 'red',
  onPress: () => {
  axios.delete(`http://localhost:3000/locales/${planLocale.id}`, { params: {
  locale_id: planLocale.id }}).then(() => {
    this.props.planLocalesFetch();
  })

你能检查一下你是否能访问这个吗?我不能用then条件修复它。
let swipeBtns = [{
  text: 'Delete',
  fontWeight: 'bold',
  backgroundColor: 'red',
  onPress: () => {
  axios.delete(`http://localhost:3000/locales/${planLocale.id}`, { params: {
  locale_id: planLocale.id }}).then(() => {
    this.props.planLocalesFetch();
  })