title: non-persisting state between function calls in React.js
body: <p>Generally, I am trying to load some data when component loads (in initialiseSellerData() ) but I only want to do this once, i.e. if page is refreshed it doesn't do it again. Please see attempt below and description of specific problem beneath</p>
  
  <pre><code>class Index extends React.Component {
  constructor(props) {
      super(props);
  
      this.state = {
          initialised: false
      };
  }
  
  componentDidMount = () =&gt; 
  {
      this.initialised()
      if(this.state.initialised == false)
      {
          this.initialiseSellerData();
      }   
  }
  
  
  initialiseSellerData = async () =&gt; 
  {
     // this function makes a call to contract to initialise data
  }
  
  initialised = async () =&gt; 
  {
      const {sellContract } = this.props
      const response = await sellContract.methods.initialised().call()
      if(response == true)
      {
          this.setState({initialised: true})
      }
  }
  </code></pre>
  
  <p>The problem I am having is that in componentDidMount, initialised() function is called correctly and initialises state gets set to true however then when do I the check for initialised it returns false (should return true). Why isn't my state persisting / being passed between function calls.</p>