Reactjs 我发现getInputData未定义的错误

Reactjs 我发现getInputData未定义的错误,reactjs,react-native,react-redux,Reactjs,React Native,React Redux,我得到这个错误,getInputData是未定义的,请问我做错了什么? getInputData只是获取用户的输入…我正在使用redux。我在名为handleInput的函数中定义了getInputData,还是定义得不好 import React from 'react'; import styles from './style'; import {Text} from 'react-native'; import {View,Input,InputGroup} from 'native-ba

我得到这个错误,getInputData是未定义的,请问我做错了什么? getInputData只是获取用户的输入…我正在使用redux。我在名为handleInput的函数中定义了getInputData,还是定义得不好

import React from 'react';
import styles from './style';
import {Text} from 'react-native';
import {View,Input,InputGroup} from 'native-base';
import Icon from 'react-native-vector-icons/FontAwesome';
import { SearchBar } from 'react-native-elements';

export const SearchBox= ({getInputData}) => {
const handleInput= (key,val) =>{
getInputData({
key,
value:val
});
}
return(
<View style={styles.searchBox}>
<View style={styles.inputWrapper}>
<Text style={styles.label}>PICK UP</Text>
<InputGroup>
<Icon name="search" size={15} color="#FF5E3A"/>
<Input style={styles.inputSearch} placeholder="Enter Pickup Location"
onChangeText={handleInput.bind(this, "pickUp")}/>
</InputGroup>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.label}>DROP OFF</Text>
<InputGroup>
<Icon name="search" size={15} color="#FF5E3A"/>
<Input style={styles.inputSearch} placeholder="Enter Drop Off Location"
onChangeText={handleInput.bind(this, "dropOff")}
/>
</InputGroup>
</View>
</View>
);
};
export default SearchBox;

你能分享一下你是如何呈现
的吗?你必须把
搜索框的父组件的代码放到
中,我已经添加了它
import React from 'react';
import styles from './style';
import {View} from 'native-base';
import MapView from 'react-native-maps';
import SearchBox from '../SearchBox';
import SearchResults from '../SearchResults';


export const MapContainer= ({region, getInputData}) => {

  return(
    <View style={styles.container}>
      <MapView
        provider={MapView.PROVIDER_GOOGLE}
        style={styles.map}
        region={region}
      >
      <MapView.Marker
        coordinate={region}
        pinColor="green"/>
      </MapView>
      <SearchBox getInputData={getInputData}/>
      <SearchResults/>
    </View>
  )
}

export default MapContainer
import {connect} from "react-redux";
import {
    getCurrentLocation,
        getInputData,
} from '../../actions/currentLocation';
import { MapContainer } from '../MapContainer';
import Home from "../../screens/Home";

const mapStateToProps=(state)=>({
    region:state.home.region,
    inputData:state.home.inputData || {}
});

const mapActionCreators = {
    getCurrentLocation,
    getInputData,
};

export default connect(mapStateToProps,mapActionCreators)(Home);