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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5275e-451c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5275e-451c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?