5 ms·
> React is not just a view rendering library anymore I was felling like this too, but I found my balance using the Controller pattern, I only use hooks in cont
by alfonsodev 6y ago
> React is not just a view rendering library anymore
I was felling like this too, but I found my balance using the Controller pattern, I only use hooks in controllers, and dispatch from controllers only, then I do not have logic in controllers, but I added some concepts of DDD having all the business logic separated, to the point I could change the whole ui framework (let's say material-ui by fluent-ui) and it wouldn't affect any controller, business logic or application types.
So with Typescript + Controller pattern + DDD concepts I'm quite happy with the separation of concerns.
This is how a route looks with Controller pattern.
<Route exact path="/:username">
<SignedInLayout backgroundType="paper">
<ProfilePageController>
{(props: ProfilePageProps) => (
<ProfilePage {...props} />
)}
</ProfilePageController>
</SignedInLayout>
</Route>
- renke1 6y agoAny example repo or more detailed description of your approach (directory structure, building blocks, rules between these etc.) that you are willing to share? – We are discussing (and using) a very similar approach to yours so we are always looking for more input (especially on the DDD part). In our case we have two widely different applications (the one being a "true" SPA with a single page and the other being a more route heavy application) and we try to converge on an approach that works for both (might not be reasonable, though).
- rhacker 6y agoThis is what I love about react. There's so many ways to do things and I feel like every now and then someone finds a new way to optimize and reduce boilerplate even more. Nice job.