I suppose "wrong tool" is a matter of opinion. In the React core docs, they specifically call out componentDidMount as the place where you should populate data calls:
To be fair, there are other things in the React docs that I don't particularly agree with. So I'm not blindly pointing to their recommendation as the unquestionable "final answer". But it's kinda difficult to label componentDidMount as the "wrong tool" when it's the exact tool named for the task in their own docs.
As for your broader point about memoization - it's a good one. I know what memoization is. But I might be able to make more practical use of it with regard to API calls. I'll have a look at your GitHub code. Thanks for the link!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I suppose "wrong tool" is a matter of opinion. In the React core docs, they specifically call out
componentDidMount
as the place where you should populate data calls:reactjs.org/docs/faq-ajax.html
To be fair, there are other things in the React docs that I don't particularly agree with. So I'm not blindly pointing to their recommendation as the unquestionable "final answer". But it's kinda difficult to label
componentDidMount
as the "wrong tool" when it's the exact tool named for the task in their own docs.As for your broader point about memoization - it's a good one. I know what memoization is. But I might be able to make more practical use of it with regard to API calls. I'll have a look at your GitHub code. Thanks for the link!