Post

Yeah, folks are getting from something that state setting in a useEffect is bad, period. So I end up getting even when it's something like this. I certainly agree sync setting is bad, but data loading like this is fine, IMHO. RQ is certainly nicer, but not required.

But honestly, I think this is a bad pattern anyway. Loading data in a React component that will render it is bad for the end user because you have to show them a loading state. It's more buttery smooth to find clever moments to prefetch and only use React once you have the data you need.

0 reposts1 like

I think calling this a bad pattern (the promise based one, not the lint rule) maybe goes too far. There are some times where this actually makes the most sense, and we don’t do anyone any favors by calling it “bad”. We need to help developers build nuanced judgment, IMO

Hmm, not sure about that. I think we get told that "this is the new way of doing things" and as developers we adopt these new patterns blindly without paying attention to the user experience. I do think this pattern is bad, based on experience, and it's ok for devs to voice disagreement with norms.

I'm glad you asked! IMO React components are best for presentation, and business logic fetching, data processing should be put somewhere else. It's best to put these things in a place that isn't automatically reactive, like a Redux environment (thunks, ect)