Best Practices - separating business logic from UI
So, I've seen this pattern which the Business logic is put into a hook, so it doesn't bloat the component.
I've also seen that some critics that having the business logic into the component is wrong
Here's a stackoverflow thread that illustrates well what I'm talking about:
https://stackoverflow.com/questions/69332889/reactjs-separation-of-ui-and-business-logic
Now, is this separation the correct way to do it, or not really? If so, how is the file structure for that?
Stack Overflow
Reactjs separation of UI and business logic
I am new to react and I find it sore in the eyes to look at the component flooded with lots of functions and variable initializations together with the UI. Is it possible to separate them?
Instead ...
10 Replies
https://stackoverflow.com/questions/69332889/reactjs-separation-of-ui-and-business-logic it's great to approach when you have huge logic
Stack Overflow
Reactjs separation of UI and business logic
I am new to react and I find it sore in the eyes to look at the component flooded with lots of functions and variable initializations together with the UI. Is it possible to separate them?
Instead ...
But is it conventional?
I mean, seems like a great pattern, but I'm afraid to bloat the files
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That's what I thought too.
Why make abstractions where abstractions aren't needed?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
YES
That's exactly what I thought. I feel like people who made that comment are the ones who came from hardcore OOP and want to OOPify React
also relevant http://react-file-structure.surge.sh/
Everytime i see someone post a ooped reqct code i vomit on the inside
this is the philosophy I've been living by and I spend waaay less time planning and much more time doing
one of the best parts of react is that you can colocate your UI and related business logic. It’s actually really good from a dev exp perspective.
IMO it’s pretty easy to make a react codebase less maintainable if you’re breaking up stuff to quickly. Theo’s take is vry good here