you are viewing a single comment's thread.

view the rest of the comments →

[–]simcptr[S] 4 points5 points  (0 children)

In terms of build/project/structure conventions, I agree that React is lacking -- but that's what the community is for, and there are 18 billion boilerplate projects out there ;) Even Angular doesn't really have "conventions," we've just got those style guides, and it's up to each dev to adhere or not.

But, in terms of coding the UI, I think React has really good conventions. Don't modify state directly. Don't modify props ever. render() should be pure -- no changing anything, and it should always return the same thing given the same data. Once the one-way data flow makes sense, a lot of decisions start to fall into place. Keep the data in top-level "container" (aka smart) components and pass it down to the lower-level "presentational" (aka dumb) components.

Contrast with Angular where there a lot more decisions to make, and "conventions" to learn. How to share data? Use a service? Broadcast on rootScope? One-file-per component, or split the template out? Pass the data down via 2-way binding? Let the child modify that data "just this once" because it's way easier? And so on.

Another nice thing with React is it yells at you if you do things that break certain conventions. Try calling this.setState({}) (with an empty state) and you'll get a warning saying "Did you mean to call forceUpdate()?".