undefined is not an object (evaluating '_this2.setProject.bind') onPress

undefined is not an object (evaluating react native
react native typeerror: undefined is not an object (evaluating
typeerror: undefined is not an object react-native
reactnativejs: undefined is not an object (evaluating)
undefined is not an object (evaluating pizza hut
undefined is not an object (evaluating e response data data error)
unhandled js exception: undefined is not an object (evaluating t calluuid)
undefined is not an object evaluating warnings filter

React native beginner here, I'm trying to make an app that runs a function when I press on my custom made component but when I try do to so, I get the "undefined is not an object (evaluating '_this2.setProject.bind')" error...

Here's my code:

constructor(props){

super(props);

projets = [
    {
        "text":"ProjectName",
        "progress":"30",
        "budget":"36000",
        "totalDays":"50",
        "design":"10",
        "integration":"12",
        "dev":"30"
    },

var progress = 0;
var totalDays = 54;
var budget = 24000;

this.state = {
  projets: projets,
  progress: progress,
  totalDays: totalDays,
  budget: budget
}

this.setProject = this.setProject.bind(this);

}

....

  setProject() {
    console.log("test");
  }

  render() {

var projectsArray = [];

return (

.....

    <ScrollView style={{flex: 3, flexDirection: 'column', backgroundColor: '#f5f5f5'}}>

      {this.state.projets.forEach(function(projet, index) {

        projectsArray.push(
            <ItemProjet onPress={() => {this.setProject.bind(this)}} selected={false} key={index} progress={projet.progress} budget={projet.budget} totalDays={parseInt(projet.design)+parseInt(projet.integration)+parseInt(projet.dev)} text={projet.text} design={projet.design} integration={projet.integration} dev={projet.dev}/>
        );

      })}

      {projectsArray}

    </ScrollView>

There are two issues with your code.

First: - You don't need to bind your function in 3 ways which makes the code redundant. Therefore you can just call onPress={this.setProject}

Second: - Rather than using forEach, pushing the array and then rendering it, you can simply use the map function which creates a new array with the results of calling a provided function on every element in this array.

Therefore you can do

   {this.state.projets.map((projet, index) => ( //... Use arrow function here to bind this parameter

     <ItemProjet key={index} onPress={this.setProject} selected={false}
       key={index} progress={projet.progress} budget={projet.budget}
       totalDays={parseInt(projet.design)+parseInt(projet.integration)+parseInt(projet.dev)}
       text={projet.text} design={projet.design} integration={projet.integration} dev={projet.dev}/>
    ))}

Undefined is not an object (evaluating myArray.length), Undefined variables are not objects, and therefore can not have properties such as length . EDIT: In order to call your function when you click the button, it is best to set the event listener in javascript rather than putting it in your HTML. @SedricHeidarizarei I'm of the opinion that with destructuring, there is no "better way". It's simply a tool to help make code more readable. Whether or not you use it depends on your style and your team's style. @SedricHeidarizarei As for pure components, there are good reasons to use them.


You should declare your function like this (auto bind to your class):

setProject = () => {
  console.log("test");
}

and then use it like this:

<ItemProjet onPress={this.setProject} //other props />

Unhandled JS Exception: TypeError: undefined is not an object , Unhandled JS Exception: TypeError: undefined is not an object (evaluating 'this.​_subscribableSubscriptions.forEach') #17348. Closed. I am using AmCharts to display a graph on my site. it worked in Safari on Aug 29th. Havn't changed anything except some text underneath the graph since then. (checked my git history). But somehow


You can use ES6 arrow functions to solve this particular use case.

In your case, you can declare the setProject() function in the following way within your component:

    setProject = () => {
      console.log('test');
    };

After this, you can invoke the function by simply typing:

this.setProject() or onClick={this.setProject}

TypeError: undefined is not an object (evaluating 'e._children , TypeError: undefined is not an object (evaluating 'e._children.forEach') #26763. Closed. mykhailo-melnyk opened this issue on Oct 8, 2019 · 9 comments. You would need to include angular.js as well, then only angular.mocks will work else window.angular will be undefined. files: [ 'dom_munger.data.appjs', 'path/to


TypeError: undefined is not an object (evaluating 't.click.length , [This thread is closed.] Hi Manos, I get this Server Error Message using the Plugin page-scroll-to-id. The issue appears in line 475 of the… The issue I faced- "undefined is not an object (evaluating RNPushNotification.getInitialNotification)". The reason- I was trying to integrate the library while using expo for running project which is not supported. You will have to eject your project using "react-native init". Doing so worked for me.


TypeError: undefined is not an object (evaluating 'dataText[i].length'), When trying to make a type-writer work, I get TypeError: undefined is not an object (evaluating 'dataText[i].length') on: if (i < dataText[i].len undefined is not an object (evaluating 'RNFetchBlob.DocumentDir') #84. Closed rameramwe opened this issue Aug 14, 2016 · 45 comments Closed


TypeError: undefined is not an object (evaluating 'e.links') » Talk , All zooniverse cookies cleared. Logged in. Clicked on Messages beneath the avatar. Got this message "TypeError: undefined is not an object (evaluating 'e.​links')"  Getting undefined is not an object in React native when rendering. I'm new to React and React native and am trying to retrieve data from an API and then render it but I seem to be running into problems. I can grab the data from the API alright, but when I try and render it I'm getting all sorts of errors.