Axios.get() Reactjs
Solution 1:
The reason for you the above code is causing a problem because here in the above code we are not using react-life cycle hooks properly and making HTTP calls in the render function. As this is the class-based component. You could try using componentDidMount() life cycle hook to make all the HTTP calls before the components load and componentUpdateMount() lifecycle hook after it updates.
If in case you are using functional components in react than in react 16 and above versions we now have react-hooks, these react hooks help us to make the same HTTP in useEffect() hook. You could read about it further from the react official website as well. I hope it will help :) https://reactjs.org/docs/react-component.html
https://reactjs.org/docs/hooks-effect.html
Post a Comment for "Axios.get() Reactjs"