# Function (http-request) is running without a Functioncall

**URL:** <https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383>\
**Category:** General\
**Created:** [September 13, 2016, 6:47am UTC](https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383 "2016-09-13T06:47:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetoCode](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vetoCode](https://forum.freecodecamp.org/u/vetoCode)\
**Post date:** [September 13, 2016, 6:47am UTC](https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383/1 "2016-09-13T06:47:48Z")

</div>

I’m working on the React-Project “Build a Camper Leaderboard” and in one of my three modules I have the problem, that the function _componentDidMount_ is running without any call in this or a other module.

The whole code on Codepen: [http://codepen.io/vetoCode/pen/YGybYz?editors=1010](http://codepen.io/vetoCode/pen/YGybYz?editors=1010)

Here you can see the LeaderBoardTableBody Module:

```
var LeaderBoardTableBody = React.createClass({
  getInitialState: function() {
    return {
      nr: '',
      name: '',
      picUrl: '',
      points30Days: '',
      pointsAllTime: ''
    };
  },
  componentDidMount: function() {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", this.props.source, true); 
    xhr.send();
    xhr.onreadystatechange = function () { 
      if (xhr.readyState != 4 || xhr.status != 200) {
        console.log('error'); 
      } else {
        var response = JSON.parse(xhr.responseText);
        console.log(response[0]);
      }
    }; 
  },
  render: function() {
    //this.componentDidMount();
    return (
      <tr>
        <td>{this.state.nr}</td>
        <td>{this.state.picUrl}{this.state.name}</td>
        <td>{this.state.points30Days}</td>
        <td>{this.state.pointsAllTime}</td>
      </tr>
    )
  }
});
```

---

<div class="post-metadata">

**Author:** ![jenovs](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jenovs/32/60963_2.png) [@jenovs](https://forum.freecodecamp.org/u/jenovs)\
**Post date:** [September 13, 2016, 7:20am UTC](https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383/2 "2016-09-13T07:20:24Z")

</div>

> [@vetoCode](#):
>
> I have the problem, that the function componentDidMount is running without any call in this or a other module

This is not a problem. It is how React works. You don’t call [Lifecycle Methods](https://facebook.github.io/react/docs/component-specs.html#lifecycle-methods) yourself, they are executed by React “at specific points in a component’s lifecycle”.

---

<div class="post-metadata">

**Author:** ![vetoCode](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vetoCode](https://forum.freecodecamp.org/u/vetoCode)\
**Post date:** [September 13, 2016, 7:23am UTC](https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383/3 "2016-09-13T07:23:09Z")

</div>

Thanks for your answer 🙂 This link is very usefull!

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 5:29am UTC](https://forum.freecodecamp.org/t/function-http-request-is-running-without-a-functioncall/36383/4 "2021-01-16T05:29:39Z")

</div>

Closed on January 16, 2021, 5:29am UTC


