Live data from Hacker News

Learn React by building a web app

udilia.com

51–60 of 107 posts

Re: Learn React by building a web app

#51
post #32

Earlier quoted context omitted.

I feel this way about React but Redux seems awkward and worthy of replacement. Am I in the minority on this?

I'm a Redux maintainer. Any particular pain points you're concerned about?

Not OP, but my day to day job is helping teams with their migration onto React (often for big sites you've used or have at least heard of). Here goes, although these probably aren't anything new to you:

– As far as I understand, Redux was intentionally made to be low-level and unopinionated, with the idea that other libraries would build on top of it. That has not really borne out and it actively makes adoption extremely painful. Everyone just uses Redux directly in their apps. As a result, adopting Redux on every team I've ever been on has been a painful process of figuring out how to fill in the blanks that Redux left out. Like how to handle async actions and side effects, how to name action creators, where to put connect()ed components, etc. And the result never feels great.

– Related to the above: it's extremely telling that I can't name a single library of reusable Redux actions/reducers/etc. Despite attempts to define things like "ducks", and there being hundreds/thousands of reusable React components published, there are none for Redux that anyone has ever paid any attention to. Because of the batteries-not-included philosophy, you pretty much just can't share your Redux code, because different apps might be building on vanilla Redux in too disparate a fashion with whatever middleware they chose. That's why I'm expecting the new Context API to displace a fair amount of Redux usage: because publishing reusable Context libraries is going to be brain-dead simple compared to reusable Redux.

– Developers just don't get what they should connect() and how to design their components, and Redux doesn't really offer them much guidance. As an example, every single day I have to mention in code reviews that something like a "loadProducts" prop does not make any sense on something like a "SearchButton" component, just because our Redux action happens to be named "loadProducts" – an "onClick" prop that just happens to be mapped to "loadProducts" in connect() makes much more sense. But devs are lazy and just end up giving components a bad design with a bunch of props that wouldn't make sense if Redux were not involved. Most of my code reviews contain the words "design your component's API without even thinking about Redux yet!"

There are more, but those are the main issues. btw, thanks for all the hard work you do!

Re: Learn React by building a web app

#52
post #32
post #17

Earlier quoted context omitted.

Eh, React is 5 years old. I've been writing it professionally for 3. I'm not worried. And honestly -- React doesn't have the same pain points jQuery/Backbone/Angular1 did where I couldn't wait to move on after 6 months. We'd have to see an absolutely massive paradigm shift before I'd regret writing my apps in React.

I feel this way about React but Redux seems awkward and worthy of replacement. Am I in the minority on this?

I created my own library after finding redux boilerplate heavy. I haven't publicized it yet, but you can see it here - https://github.com/gunn/pure-store

It supports full typescript typing, and uses Immer to allow very direct store updates with immutability.

Re: Learn React by building a web app

#53

I fear that by the time I'm good enough at react, another library will come out

You could start with mithril.js, it's a react-like vdom library with a minimal set of api, and vanilla JS for everything else.

I've been using it the past 6 weeks and super happy with it. I'm sticking with the hyperscript form of it, but you can use JSX if you want.

Re: Learn React by building a web app

#54
post #34
post #32

Earlier quoted context omitted.

I feel this way about React but Redux seems awkward and worthy of replacement. Am I in the minority on this?

There are tons of options for State Management before you even need Redux. Check out: Context API: https://reactjs.org/docs/context.html Unstated: https://github.com/jamiebuilds/unstated MobX: https://github.com/mobxjs/mobx

Meiosis is a simple state pattern, a very elegant approach to handling state: http://meiosis.js.org

Re: Learn React by building a web app

#55
post #6

One thing completely missing from courses is how to handle animations. Most React apps have no animations whatsoever (including mine, because I have no idea how to implement them), but they're important for usability IMHO.

Pose [0] was posted on HN a few days ago. I haven't tried it, but its API looks super clean. HN Discussion [1] [0] https://popmotion.io/pose/ [1] https://news.ycombinator.com/item?id=16701756

I got excited about Pose but when I tried it out I saw a lot of unexpected and undocumented behavior. Seems promising but docs needs more work and examples!

Re: Learn React by building a web app

#56

I fear that by the time I'm good enough at react, another library will come out

It seems that way, but the fundamentals are simple: functional/declarative programming using self-contained components, just like using regular HTML tags where you pass in all the attributes in the tag to customize it, but now with javascript for much more flexibility in what you can pass in via those attributes.

Those fundamentals are useful everywhere, like backend event-sourcing, CQRS, message-driven actor systems, and even all of the other libraries like Vue, Angular, etc. Learning any of these is like learning 80% of the rest.

Also React has some of the best release and upgrade notes along with tooling so that you can take an app through versions very easily.

Re: Learn React by building a web app

#57
post #6

One thing completely missing from courses is how to handle animations. Most React apps have no animations whatsoever (including mine, because I have no idea how to implement them), but they're important for usability IMHO.

I really like React Motion [0] because the API is really simple and the concepts are pretty easy to grasp. If you like the concept of Pose (springs), React Motion might be more predictable.

[0] https://github.com/chenglou/react-motion

Re: Learn React by building a web app

#58
post #32
post #17

Earlier quoted context omitted.

Eh, React is 5 years old. I've been writing it professionally for 3. I'm not worried. And honestly -- React doesn't have the same pain points jQuery/Backbone/Angular1 did where I couldn't wait to move on after 6 months. We'd have to see an absolutely massive paradigm shift before I'd regret writing my apps in React.

I feel this way about React but Redux seems awkward and worthy of replacement. Am I in the minority on this?

I've been using redux-zero on my latest projects with reasonable success. It does away with the distinction between actions and reducers, so you're basically just calling functions that update the app state.

This eliminates almost all boilerplate-ish code compared to redux, but it comes with its own caveats. I think it's a solid choice for small to medium size applications.

https://github.com/concretesolutions/redux-zero

Re: Learn React by building a web app

#59
Not a single lesson titled: "How to write tests"

With snapshots, while not perfect, they do catch a lot and are easy to do (and more importantly, easy to update when things change). React components are relatively easy to further test with enzyme and jest.

Without a focus on instructing people how to do testing, people never bother.

Re: Learn React by building a web app

#60

Earlier quoted context omitted.

That's why I am going to wait till next year to start learning JQuery. Should be stable and mature by then.

Too late, http://youmightnotneedjquery.com/

The left column of that site only confirms (for me) how much friendlier Jquery is and that I don't want to give it up.
Post reply on HN