Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.js vs React.js with php mvc (Laravel)

I know what angular.js is and I even had a question about it @Why use AngularJs in frontend if Laravel is already used as backend?.

but recently I started to read about React.js and from its site (its the V in the MVC) which is exactly what am after "handling the view and nothing else".

for me, I think Angular.js as an MVC framework was made to be used with something that is built with JavaScript from start to end like Node.js

and it seems like an overkill when used with something like Larval, where I simply need something to handle the frontend and nothing else + Angular have 2 main drawbacks

  • with the latest news about a new version that won't have back compatibility with the current version makes me even feared to start learning it just to find that more or less every project out there is using the old version which mostly is true.

  • angular renders the whole dom if anything got changed which again is an issue for big projects.

so based on the above, plz note that I want to learn/use JS solely to enhance the user experience not to build another Gmail or Facebook and so my question is,

could React.js be used with Laravel to handle the view and do everything Angular was going to give, or I have to use Angular liked or not?

like image 573
ctf0 Avatar asked Dec 21 '14 06:12

ctf0


1 Answers

could React.js be used with Laravel to handle the view and do everything Angular was going to give?

No

React is just for views. React components are stateful components with some really clever rendering stuff happening behind the scenes. To build a fully functional front-end app, you'd need to tie in some other code (or write it yourself).

React works well with Facebook's Flux architecture. I would suggest looking into that to learn how to manage the state of your react components.

What's key to understand here is that Flux and React are not parts of a large front-end framework. React is a library and Flux (as provided by Facebook) only provides a Dispatcher. The rest is up to you to implement. There are some pre-existing implementations you can look at if you need some help to get started.

What I like about flux is that it allows me implement things the way that fits my application best. React takes care of the heavy DOM lifting and is very easy to learn. Compared to Angular, I don't have to learn arbitrary conventions and gigantic APIs of a huge framework.

like image 145
maček Avatar answered Sep 20 '22 14:09

maček