Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

this.props.onPress is not a function, is an instance of an object #11

Open
sagomezza opened this issue Dec 19, 2017 · 1 comment
Open

Comments

@sagomezza
Copy link

Hi, I'm getting this error when I try to implement the camera in my project:
captura de pantalla 2017-12-19 a la s 4 40 22 p m

The project has the next structure:
A main screen (I'm using react-navigation) from which I can access others screen through some buttons. In one of those screens, there's a button that calls the camera, when I hit that button I the error occurs.

But, if try the camera and the gallery apart, I'm not getting any error.
Also if I delete all the onPress props from all the TouchableOpacity tags on Camera and Gallery, I'm still getting the same error, which is pretty weird.

Anyone knows why is this happening?

@shandilya1998
Copy link

I'm getting this error, when i try to go from one screen to another.

class TripsScreen extends Component{
  constructor(){
    this.FunctionToCustomItineraryBuilder = this.FunctionToCustomItineraryBuilder.bind(this)
  }

  static navigationOptions = ({navigation}) =>({
    title : "TripsScreenOptions",
    headerVisible: false
  })

  FunctionToCustomItineraryBuilder(){
    this.props.navigation.navigate("Second")
  }
  
  render()
  { 
      return(
          <ImageBackground
              source={require("../../assets/images/bg.png")}
              style={styles.bg}>
              <View style = {styles.appTitle}>
              <Text style = {styles.appTitleText}>TRAVEL APP</Text> 
              </View>
              <View style = {styles.tripScreen}>
                <View style = {styles.tripScreenOptionsView}>
                  <TouchableOpacity onPress = FunctionToCustomItineraryBuilder() style = {styles.tripScreenOptionButton}>
                    <View>
                      <Text style = {styles.tripScreenOptionText}>Build an itinerary</Text>
                    </View>
                  </TouchableOpacity>
                  <TouchableOpacity style = {styles.tripScreenOptionButton}>
                    <View>
                      <Text style = {styles.tripScreenOptionText}>Planned Trips</Text>
                    </View>
                  </TouchableOpacity>
                  <TouchableOpacity style = {styles.tripScreenOptionButton}>
                    <View>
                      <Text style = {styles.tripScreenOptionText}>Previous Trips</Text>
                    </View>
                  </TouchableOpacity>
                </View>
              </View>
          </ImageBackground>
          );
  }
}

Any explanation why? StackOverflow suggested binding the function being used for navigation (here FunctiontoCustomItineraryBuilder), but that doesn't help either.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants