0

Working with react-native is mega frustrating. Its more frustrating because I am new to it. I have written component that takes redux action as an input.

import React from "react";
import {Text} from "react-native";
import styles from "./searchBoxStyles";
import {View,InputGroup,Input} from "native-base";
import Icon from "react-native-vector-icons/FontAwesome";

export const SearchBox = (getInputData,selectedSearchTab) => {

    function handleInput(key,val){
        getInputData({
            key,
           value:val});
    }

    return(
        <View style={styles.searchBox}>
            <View style={styles.inputWrapper}>
                <Text style={styles.label}>PickUp</Text>
                <InputGroup>
                    <Icon name="search" size={15} color="#FF5E3A"/>
                    <Input onFocus={()=>selectedSearchTab("pickUp")} style={styles.inputSearch} placeholder="choose pickup location" onChanangeText={handleInput.bind(this,"pickUp")}/>
                </InputGroup>
            </View>
            <View style={styles.secondInputWrapper}>
                <Text style={styles.label}>DropOff</Text>
                <InputGroup>
                    <Icon name="search" size={15} color="#FF5E3A"/>
                    <Input onFocus={()=>selectedSearchTab("dropOff")} style={styles.inputSearch} placeholder="choose drop off location" onChanangeText={handleInput.bind(this,"dropOff")}/>
                </InputGroup>
            </View>
        </View>
    );
};

export default SearchBox;

getInputData & selectedSearchTab are both redux actions, passed down from container component.

Clicking on the textBox I get selectedSearchTab is not a function error.

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
user1663148
  • 61
  • 1
  • 1
  • 4
  • Share you code how you get called SearchBox component? – Nirmalsinh Rathod May 20 '18 at 09:29
  • import SearchBox from "../searchBox"; export const MapContainer = ({region,getInputData,selectedSearchTab})=>{ return( ) } to this component as well , it is passed down by parent component. passing is done by this.props.selectedSearchTab . this is mapped to container using redux connection(state,action) call. – user1663148 May 20 '18 at 09:34
  • Can you check that you are passing correct Method as props in MapContainer. The issue is in passing method. – Nirmalsinh Rathod May 20 '18 at 09:37
  • const mapActionCreators = { getCurrentLocation,getInputData,selectedSearchTab }; i do not see any issue i guess – user1663148 May 20 '18 at 09:40

0 Answers0