title: How to use props value in non component class which imported in component in React
body: <p>I would like to access <code>this.props.apiendpoint</code> in <code>api.js</code> which imported in <code>test.js</code> which is component base class.</p>
  <pre><code># api.js
  import axios from 'axios';
  export function fetchData(){
     return axios.post(apiendpoint);
  }
  </code></pre>
  <pre><code># App.js
  import test from test.js
  export default class App extends Component {
    constructor() {
      this.apiendpoint = 'api.example.com';
    }
     
    render() {
      &lt;test apiendpoint = {apiendpoint} /&gt;
    }
  }
  
  </code></pre>
  <pre><code># test.js
  import PropTypes from 'prop-types';
  import {fetchData}  from api.js;
  
  const test = ({
  }) =&gt; {
     console.log(this.props.apiendpoint); // this value how to acccess in api.js 
     fetchData();
  }
  test.propTypes = {
  apiendpoint: PropTypes.String,
  }
  test..defaultProps = {
  apiendpoint : null,
  }
  
  </code></pre>
  <p>like <code>fetchData()</code> I have many functions for API related passing <code>apiendpoint</code> for each function not good practice.</p>
  <p>any help will be appreciated.</p>