8

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?

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
ctf0
  • 6,991
  • 5
  • 37
  • 46
  • 1
    What facebook means by saying it doesn't handle the M and C is that it doesn't worry about fetching data from the backend,whether its rest or something else. Doesn't handle data binding. Angular does support this. So if you have a REST api, you can tell angular and voila it will take care of GET, PUT and Delete requests. You are still free to use angular just for the views – SoWhat Dec 21 '14 at 07:05
  • 1
    I feel like this is a matter of opinion. The boiled-down truth is that you can just about always make *whatever* work with **whatever else**, it's just a matter of how much work that may or may not entail. I've seen and done plenty of strange combinations of technologies simply because it was what I had to work with. – Jhecht Dec 21 '14 at 07:07
  • I've been using it with ASP.NET MVC for quite some time now I'm loving it. – Dimitar Dimitrov Dec 21 '14 at 07:34

1 Answers1

10

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.

maček
  • 76,434
  • 37
  • 167
  • 198
  • which IDE do you use for building apps with Flux? – wolfgang Jun 12 '15 at 19:29
  • 1
    @wolfgang, I don't use an IDE. I use a simple text editor. – maček Jun 12 '15 at 21:20
  • 1
    does'nt it bother you that a lot of "best practices" and profusely used features (session handling, authentication, sql injection protection etc.) come out of the box with laravel and in the case of flux you might have to do/code this yourself (or re-invent the wheel) especially when building a large app? – wolfgang Jun 13 '15 at 06:05
  • @wolfgang you seem to be misunderstanding the technologies here. React + Flux are front-end technologies. If you want to use Laravel in your back-end, you still can. – maček Jun 14 '15 at 00:52