Why Laravel Blade and Not React

Let’s have this discussion in a new thread then. :smiley:

So I’ve just begun trying out Sage 9 for the first time. Blade’s a big learning curve, and I’ve spent a lot of time wondering ‘why is this a benefit’ and finally had an ‘ah ha!’ moment with @yield and @section's today.

But I am keen to know if there’s a discussion to be had between Blade and React (are they comparable?), or in general what React’s future is in theme dev.

I haven’t even begun to look at React but it’s all the internet is talking about (outside the WP community) and I’ve got a bit of FOMO… keen to know others thoughts.

2 Likes

I understand why Blade vs React is a strange question because they’re seemingly very different. The reason I asked it was because they have a similar concept of building components and temptlating while cleaning up the base code.

As far as React goes, I was all for them a couple years ago but with recent events and less trust in Facebook’s ethics, I’ve been leaning towards Vue.js more (as have a lot of other people). Not saying one is right, one is wrong, but before you commit to React definitely dedicate some research to Vue.js as well.

Why React and not Vue? :smiley:

3 Likes

https://dev.to/maxlaboisson/strapping-reactjs-on-a-wordpress-backend-wp-rest-api-example-8c7

As a user of Sage, blade eased my introduction to templating because it’s so similar to the way WordPress works without Sage. It’s largely an aesthetic difference, but blade SEEMS easier to tackle because it’s still PHP. If, back when I was getting ready to move from Sage 8 to 9, I had read the equivalent of “you also have to learn that huge React thing you keep reading about and are more than a little scared of” I probably wouldn’t have hopped on board. Blade, however, was a single stepping stone rather than a total reconfiguration of how I develop themes.

Not to mention the patent fiasco that Sage neatly avoided having to deal with.

I’m sure there are other good reasons, some of which may simply be preference among the development team, but I found the choice of blade very helpful in bringing me around to the Sage way of doing things.

2 Likes

@stacks are going to blow your mind:

1 Like

I’m not totally sure of this because I haven’t built stuff using React although I’ve read a lot about it. My understanding is, If you’re building a single-page webapp this question might make sense. But WP is used mostly for “presentational / communication / marketing” oriented websites. Using React could penalize your objectives because of the heavy initial page loading time and the rather unsemantic way it outputs html, thus impacting SEO. So : fine for apps, not so much for websites that are not visited recurrently by the same user in a short amount of time, and that need strong SEO.

1 Like

The html could easily be identical now with React 16 I believe. No unnecessary wrappers needed anymore and you could probably even use blade/php as server side rendering, then hydrate the app and let react take over when it has loaded in the browser. I guess this was always possible but should be easier to do now. Anyway most things built with Sage needs the loading time and SEO advantage of server side rendering so think that is the main reason react in the browser as the only rendering might be a bad idea for most projects, but might be a good idea for some more app like features on the site if needed, and in those cases I would make it as a separate plugin and not in the theme.

2 Likes

Not trying to be rude here, but to state the obvious:

Blade is a PHP templating engine. React is a “JavaScript library for building user interfaces”. Considering that WordPress is a PHP based CMS which lacks a real templating engine… well Blade is a perfect fit. React is not.

Of course any kind of technology/solution which results in a user interface being rendered in HTML could work, but that’s not really the point. I personally don’t think they are comparable at all.

And WordPress + React can be used and it can work well. It’s just not a great fit for Sage.

7 Likes

nope! nope! nope!

and what @swalkinshaw said

also this

I figured as much! Just curious like I mentioned since I’ve only just started with Sage 9 and keep hearing about React … and constantly wondering what’s next.

1 Like

Well you can still integrate JS Frameworks (I used Vue multiple times) to have reactive sections for your site.
They are not used only for routing, you can have multiple scopes to use a JS framework.
Still I would like to remove jQuery :slight_smile:

1 Like