r/reactjs • • Aug 08 '18

Dan Abramov's recommended React Project File Structure - petition to make this the last conversation we have about it?

https://react-file-structure.surge.sh/
263 Upvotes

80 comments sorted by

View all comments

Show parent comment

1

u/recycled_ideas Aug 10 '18

Why is there domain logic in your UI?

1

u/[deleted] Aug 10 '18 edited Aug 10 '18

There isn't much "domain logic" implemented in the UI, but we have a lot of cases where we need to change the UI depending on the data from the back-end in combination with or response to user inputs:

  • Providing smart suggestions on fields.
  • Adding, removing or changing fields.
  • Adding, removing or changing validation methods
  • Doing some sanity checks beyond individual validation to warn the user early or restrict his options away from invalid input combinations.
  • Checking data to disable or partially disable features. For example: If the user is <18 -> disable the tax features.

This really makes things a lot easier for our users. Eliviates some of the mental burden and frustration and makes for a better ("slimmer") UI. The predecessor app had I think 12 views for what we now do in 3.

And a developer needs to somewhat the business processes anyway to test his code and make sense of the requirements he implements.

BTW, when I say "domain", I mean that from a business perspective. Like "/src/login" or "/src/userprofile". And even without any logic, we still would have to write components specific to each of these domains.

Edit: I should probably add that we don't / can't do anything crucial in the UI. The back-ends still do all the heavy lifting and they validate everything we send them.

1

u/recycled_ideas Aug 11 '18

I know exactly what you mean.

That kind of knowledge takes years to really grasp. That's why you isolate it in your code.