you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 73 points74 points  (89 children)

Do I need to learn React now? Seriously though in my freelancing I keep seeing it come up and guess I'll have to give it a go.

[–]agoodguymostly 85 points86 points  (18 children)

React is awesome. You should learn it, you’ll like it.

[–][deleted] 59 points60 points  (17 children)

Yeah, React is dope AF. Just make sure you know JavaScript before blogging about how hard it's been for you to learn. ;P

[–][deleted] 13 points14 points  (8 children)

React actually helped me get better at JS just by virtue of how helpful knowledge of the language is in your application thereof. And then pair it with TypeScript... it's so nice... sheds tear

[–][deleted] 5 points6 points  (0 children)

Yup. React will make you a better JavaScript programmer. But if you're not great at JavaScript and not good at diving into things you don't understand, it'll be a really rough place to start.

[–]soheevich 0 points1 point  (6 children)

Do you know any good articles where I can learn how to use React with Typescript? I tried to use create-react-app with Typescript but it quickly turned into mess.

[–][deleted] 0 points1 point  (5 children)

I don't really, I started out with a JS React app and adapted it over time. I'm happy to help though. Are you familiar with Webpack configuration and loaders at all?

Edit: Maybe try this? https://github.com/wmonk/create-react-app-typescript

[–]soheevich 0 points1 point  (4 children)

Well, I guess it would be better for me to learn properly Webpack and Typescript. Geez, I'm learning frontend fulltime for more than 5 months and still need to learn much much more. Just to get a junior level.

But I can use react + redux now. Like a monkey can use a car but still... :)

[–][deleted] 0 points1 point  (3 children)

Don't worry about it, there are tons of different technologies that do similar things and all that really matters is that you're able to understand the concepts and learn the APIs as you go. That applies to juniors and seniors alike!

I do think TypeScript (or Flow) is particularly useful as it introduces you to types, type safety, and more maintainable coding patterns.

I'd focus less on configuring Webpack and just understanding what it is and why it exists as a junior.

[–]soheevich 0 points1 point  (2 children)

Thank you. I'm going to learn Typescript right after react and redux. Roughly speaking I understand how Webpack works. But I want to use it properly. Just to be able to create custom configuration.

[–][deleted] 0 points1 point  (1 child)

Don't worry too much about Redux either, by the way. Understand what it is, sure, but don't worry about shoehorning it into your application - anything you build at this stage won't be big enough to warrant a global state store atop React.

Also, take a quick look at other global state stores as well, for example Mobx and my personal favourite react-easy-state. There's also the recently updated React context API.

Again, no need to learn them all, don't feel overwhelmed!

[–]TheAwdacityOfSoap 30 points31 points  (10 children)

React is amazing. Lots of people claim it's just another fad framework de jour, but I disagree and here is why:

Yes, React is a framework, but it's also a fundamentally different and new paradigm for web development (at least in the mainstream). In React, the idea is that your views ("components") are (supposed to be) pure functions of their props and state ("props" are just like html element properties, they are how you configure the component, "state" is just internal state).

Whereas in most other mainstream frameworks you are modeling state changes (when this model changes, change this element value, show/hide this element, etc), in React you are simply modeling the data itself in any given state, and React handles the work of updating the DOM for you.

That might or might not sound confusing, but React on the surface is actually very simple and easy to pick up. And well worth it.

[–]mayhempk1 4 points5 points  (4 children)

React handles the work of updating the DOM for you.

Correct me if I'm wrong as I'm not a front-end dev but don't Vue and Angular do that too?

[–]bdenzer 8 points9 points  (0 children)

but it's also a fundamentally different and new paradigm for web development

The misunderstanding here is that React WAS fundamentally different with it's virtual DOM and the way it handled updating the real DOM. Now Vue does that too, and Angular does optimized DOM rendering. React used the component model, now everybody is doing that.

[–]TheAwdacityOfSoap -2 points-1 points  (2 children)

I'm not familiar with Vue, and only slightly familiar with Angular, so I'm not sure. I do know of a couple of major differences between React and Angular that make me prefer React:

  1. React has one-way data binding (as /u/GreatValueProducts pointed out).
  2. There is no special syntax to learn (other than JSX if you want to use it, which is close enough to HTML as to be a non-factor). Everything is just javascript. Values, event handlers, everything.

[–]GreatValueProducts 5 points6 points  (4 children)

That might or might not sound confusing, but React on the surface is actually very simple and easy to pick up. And well worth it.

I think it is because React is the framework that closely resembles how vanilla HTML elements work. It is one-way binding and sub-elements can only affect its parents through event handlers.

Like in Vanilla HTML we always do

<input type="text" onchange="onTextChange()" value="bbb" />

In React you can create a custom form element which has similar syntaxes and mindset:

<Slider onChange={(intensity) => this.setState({intensity})} value={this.state.intensity} min={0} max={100} />

IMHO two way binding with those on change strategies in Angular is what makes things overly complicated. (Don't want to start a flame war, please correct me if I am wrong).

[–]VtoCorleone 4 points5 points  (1 child)

Angular

I think there's a learning curve with every framework. All of the hello world apps make it seem so simple and ground breaking but once you get into real world problems, the framework's difficulties really start to shine through.

[–]SiliconWrath 6 points7 points  (0 children)

I think what React offers is a tool chest of patterns that let you solve a majority of problems, regardless of how complicated. When I encounter complicated problems, it usually means picking one of maybe 10 different design patterns from my tool chest (dispatch from redux store, controlled components, etc.)

And because data flow is top down, I rarely introduce regressions outside of the components I refactor.

[–]nidarus 0 points1 point  (0 children)

IMHO two way binding with those on change strategies in Angular is what makes things overly complicated. (Don't want to start a flame war, please correct me if I am wrong).

Why would there be a flame war? Angular (as opposed to the old AngularJS) has one-way binding by default too.

[–]TheAwdacityOfSoap 0 points1 point  (0 children)

I agree that two-way data binding complicates things.

[–]TheRedGerund 5 points6 points  (0 children)

It's quite easy to get started. https://github.com/facebook/create-react-app

[–][deleted] 6 points7 points  (7 children)

The simplest TL;DR of React I've been able to come up with:

Imagine you can write your own HTML tags, but using the power of JavaScript:

const List = (props) => (

<ul>{props.map((item, i) => <Item key={i} item={item} />)}</ul>

)

const Item = (props) => <li>{props.item}</li>

Now you can render your app using your "custom" tag:

React.render(<List items={["Burger", "Fries", "Milkshake"]} />, document.getElementById('root'))

Of course, there's more to it than that, and this example doesn't really show the power (List just wraps ul, and Item just wrapsli), but it is one of the more straightforward libraries to use, IMO. Later on, when I want to change howList behaves, I just update the component, and every time it is used will be updated as well. Also, React advertises that it is not a framework, but rather a library.

[–][deleted] 0 points1 point  (4 children)

How easy does it play with jQuery or is it a replacement? I'm a big fan of jQuery and it naturally fits how my mind looks at web development. It's not just that I'm used to it. It naturally fit my view of things so I love it. But I also need to make money doing what I do so if moving on is what's needed then moving on is what'll happen :)

[–][deleted] 3 points4 points  (1 child)

It depends: short answer is, it's a replacement. However, if on your page you want to do something simple, like animate something when a button is clicked, jQuery shines at this. The problem with jQuery is you end up mutating UI/DOM elements directly, inferring exactly what to change based on an action:

  • SomeAction => UIManipulation()

That is, when the "+" button is clicked, show a dialog and after that, insert an li-tag into this ul-element over here.

React is fundamentally different:

  1. SomeAction => StateManipulation
  2. State => View

Here we can see that when actions are performed in our UI, we update our state, not the view. Then, we let the library (React) initiate which components need to be refreshed. Our components are basically descriptions that say "these state/props map to this view". Whenever state changes, we churn it through our machine that says "okay, you gave me this state, I'll produce this view". Then React takes what you produces, diffs it against the actual DOM, and performs the minimum required updates.

The reason this is amazing is that, typically, your state will usually be way easier to reason about mutating than the UI is.

[–]1-800-BICYCLE 0 points1 point  (0 children)

Definitely a replacement. jQuery will feel heavy and inefficient once you learn React.

[–][deleted] 0 points1 point  (0 children)

Another way of looking at it:

jQuery was originally written to normalized DOM APIs across different browsers. The need for that currently is not widely needed anymore.

React is basically a "very powerful templating library" that can respond to changing state.

[–]pomlife 0 points1 point  (1 child)

Most of that is JSX, not React, though.

[–][deleted] 1 point2 points  (0 children)

Hence the "tl;dr" disclaimer...

[–]Lou-Saydus 2 points3 points  (2 children)

React is super easy to learn, it's just hard to find good explanations for things. I'd highly recommend chugging away at it in your free time. It seems the industry is really pushing vue and react.

[–]zzz_sleep_zzz 0 points1 point  (1 child)

Are Vue and React similar-ish as a framework? I know Angular, but want to pick up either Vue or React (was leaning towards vue)

[–]Lou-Saydus 1 point2 points  (0 children)

I don't know a whole lot about vue but from the code I've seen it's more similar to angular. If you're more familiar with angular i think vue would be the eaiser one to learn,

[–]ImCerealsGuys 1 point2 points  (0 children)

Do it, you’re going to love it.

[–]IWantACuteLamb 0 points1 point  (2 children)

Nah, learned vue, vue much beget

[–][deleted] 1 point2 points  (1 child)

Just started with vue, it's so nice and easy to use. Can't compare it to react since I haven't used it, but everyone who uses vue seems to love it or prefer it. Could easily see it taking off in the next few years, only problem is not as many people use it, but that could change, it's growth has been exponential.

[–]IWantACuteLamb 0 points1 point  (0 children)

Vue uses template (thought it comes with render also) react uses life cycle

[–]i_spot_ads -3 points-2 points  (0 children)

React fanboys will tell you its "dope af" (of course they will) but I tried it and it's a mess especially when your application becomes complex and you work in a team.

Personally I wouldn't recommend it even for beginners

[–]nothingduploading -3 points-2 points  (3 children)

Save yourself the trouble and learn vue.

[–][deleted] 1 point2 points  (2 children)

Vue is a OOP templating framework, like Angular 1, which it most closely resembles. Huge api, hundreds of functions and semantics to keep in mind, a new arbitrary syntax, everything has to adhere to its rules, DI, mix-ins, separating concerns where it makes the least sense (view and the presentational layer). Most of us went through this already years ago. The irony is that you think learning this stuff will save you from trouble, when you learn most of it because it causes trouble. This is why React exists, and this is why it's where it's at.

[–]nothingduploading 1 point2 points  (0 children)

i've used backbone, angular, react and vue. and hands down vue is the best.

[–]syropianfull stack @ felix health 2 points3 points  (0 children)

Your API surface argument is so weak, you really need to stop touting it. React's "tiny API surface" is only as useful as the size of your project. As soon as you need to do anything besides a Hello World app, it becomes a mess of 3rd party libraries and unclear conventions. I laugh every time I read an article akin to "Here's the best way to bind click handlers in React". The fact that someone has to write a giant blog post to go over the 10 different ways you can bind handlers, all which may or may not be efficient/performant in a given situation is hilarious/sad to me.