What is the mainstream method for react to get data rendering asynchronously?

usually I call api, from componentDidMount and plug it into setState. This process is equivalent to render rendering twice, but if you get api in componetWillMount, you will render render, only once. But this lifecycle is not recommended now, so what"s a better solution to get data asynchronously to render pages

?
Jan.11,2022

take a look at this: https://codeshelper.com/q/10.


use the first one. It doesn't matter twice. Based on the DIFF algorithm, only those DOM that need to be updated will be updated


.
getting api in componetWillMount will render render only once

get data asynchronously render has been executed render twice

Menu