Asynchronous xmlhttp request in react

后端 未结 4 1319
感动是毒
感动是毒 2021-02-10 05:16

I am trying to implement asynchronous XMLHttpRequest in react. Here is my attempt:

4条回答
  •  忘了有多久
    2021-02-10 05:33

    I'd recommend hooking to the componentDidMount lifecycle event and make your request there. Then, once it has finished, call setState to update the state which will re-render your component. Check out the video here if you need more info:

    https://www.youtube.com/watch?v=YpM3YK9Uue0

提交回复
热议问题