Live data from Hacker News

My struggle to learn React

bradfrost.com

151–160 of 218 posts

Re: My struggle to learn React

#151
post #12

This is a fine article. But I just want to say, as an alternate data point, my experience has been exactly the opposite . I love React. React is the first front-end technology I have ever managed to get to stick. * ES6 is just a detail, I know. But for me, ES6 transforms Javascript from an idiosyncratic scripting language where I constantly have to look up the ordinary way to handle basic programming tasks into somet…

>>* The tooling was a disaster before create-react-app. But now there's create-react-app, so the tooling isn't a problem. But what happens when you inevitably need to step outside the boundaries set by create-react-app? From that perspective, it simply delays the problem, rather than solving it.

> But what happens when you inevitably need to step outside the boundaries set by create-react-app?

Been working on a real-world c-r-a based project for 8 months and this is yet to happen. And the upgrade process has been a dream (update 1 dependency), no breakages so far.

In fact I now regret my other attempts to go off the rails (adding Sass), it wasn't worth it.

Re: My struggle to learn React

#152

Honestly I don't know how I learned React. It's not fun at all. Oh sure, the basics of React is not too hard. If you ignore all the outdated examples and code (using var, no JSX, overusing component lifecycle, not using functional components). But then learning Redux, React Router, React JSS, Reselect, Redux Thunk, Webpack, etc., is just terrible. Sure, there are tutorials for each individual library, or maybe even t…

I recommend the e-book Fullstack React ( https://www.fullstackreact.com/ ) (I have no relationship to these guys, other than being a customer). I have had junior engineers read it in the past to get up-to-speed and it does a great job of teaching all of those technologies together in a way that makes sense and is easy to understand.

Let me also add that it doesn't teach them all at once. It starts from first principles and adds on new libraries as the tutorial apps become more complex.

Re: My struggle to learn React

#153

I think I can understand the struggle of the author. I experienced JS as a non-robust / fast-moving programming environment. Frameworks, Buildsystems and Language Features that change every few month. So when I first heard, that React is the new thing and everyone should use it, I did not want to use it. I use React now everyday and I really like it. But instead of writing it with JavaScript I use ClojureScript with…

> and Language Features that change every few month On the other hand, there was a period where JS devs could use one new language feature in a decade. And when it did come, it was ActiveX. (I'm exaggerating, but not by much.) From this perspective, it was kind of inevitable that at some point JS will overdo this and become a kitchen sink. I tried using ClojureScript in its early days, but the JVM ecosystem was painf…

> I don't see a point in having very similar, but not 100% compatible languages on backend and frontend.

I have an applications consisting of frontend cljs code, backend clj code and some code that will be compiled to both ends (called cljc). Even if its not 100% compatible, I think its helpful that I only have to write data validation (e.g. clojure.spec) once and can use it in every part of the system. Also if you wrote pure algorithms for complex data structures, its nice to use it in cljs and clj. The parts that are missing to 100%, can often be bypassed with a simple reader conditional (https://clojure.org/guides/reader_conditionals).

> Some time ago (a year or two, I think?) CLJS got bootstrapped - is it finally possible (and practical) to use with node only?

I dont have much experience with this, but I think that shadow-cljs (http://shadow-cljs.org/) will make this mostly possible.

Re: My struggle to learn React

#155
post #149
post #73

Earlier quoted context omitted.

React Router v4 is particularly difficult to get used to when compared to earlier versions. While I don't much mind it (I get it working, then I don't need to touch it anymore), it definitely took me some time to wrap my head around it. So yeah, it works good when you get it working, so yeah, the best thing to do is to just buck up and learn if it you need it. But boy does it suck getting there. All of that said, I d…

> Say, if you keep you containers, reducers, and actions in their own directory trees. That layout is the biggest reason it took me so long to understand it when my team brought it in. It goes a bit against the spirit of Redux, but the tutorials really should pair up action and reducer in the same directory, then later explain why the other way is also useful. We currently do this: state/ |---some_piece_of_state/ | |…

Redux itself doesn't actually care how you organize your file structure (per the FAQ entry at https://redux.js.org/faq/code-structure ).

For the size of the tutorials, it's probably simpler to use a "folder-by-type" structure. But yes, for real apps, I myself have settled on a "folder-by-feature" structure. Note that either approach is completely orthogonal to whether you have multiple reducers listening to the same action.

The tutorial is already trying to explain a lot of concepts that are new to most people, so we try to keep it focused on the meaningful concepts. Throwing in side discussions on folder structures would probably add more confusion at that point in the learning curve.

Re: My struggle to learn React

#156

Earlier quoted context omitted.

You're not wrong for beginners. They shouldn't use all or any of these tools starting out. But when you reach the point where you understand React and you start to reach the limits of React's features, i.e. inline styles isn't cutting it anymore, setState is growing too big and too complex, etc., that's when it starts to get hairy. Because continuing down the path of pure React is painful, but learning all these damn…

I think far more people get lost trying to learn the libraries than grow an app to a size where pure react too painful. First time I used react I hated it, because everything was done through flux, want to add a field to a form. Now you need to update 4 different files and create 8 methods. Not to mention interacting with non-react components in a react way can be super painful. It was insane. Second time I dropped a…

I had a similar experience with Redux, every event in the app went through redux. Click button > redux event fired > redux updates state > component catches state update > button listener fires.

It is a total nightmare and a horrible use of redux. That is like binding every variable and function to the window object because you have no concept of scope.

Re: My struggle to learn React

#157

Earlier quoted context omitted.

>> But the point would be to start with the basics and build up an understanding of why we need these libraries. And what problems they solve and what problems they don't solve. This is exactly what the well-written official React docs do. It doesn't involve any CSS-in-JS, Redux, Thunking, Webpack, etc. 1) Start off with a basic app - build the Tic-Tac-Toe app through the official React docs 2) Build a simple React a…

Yeah, I guess I'm not giving the documentation enough credit here. The main issue I see is all the companies rewriting their applications in React. Because I don't think they see it as a complicated engineering decision with tradeoffs and potential issues. They see it as "we need x buzzword and y buzzword". I'd prefer that the documentation outright say "This is a BAD idea if you're just doing xyz" instead of "if you…

Writing docs is hard. To quote Dan from when he was writing the initial Redux docs:

> So hard to write the new docs. Many different audiences to cater to. Should make sense to: Flux beginners, FP people, FP people who don't get Flux, Flux people who don't get FP, normal JS people too. Flux people: “is this proper Flux?” FP people: “is this that weird thing called Flux?” Normal people: “why not Backbone”

Both React and Redux introduce a lot of new concepts for someone coming from a typical jQuery / Backbone-type background. The larger the example apps you show, the more potential there is for them to get lost on what concepts are actually relevant (which is actually part of what Brad was saying in the original linked post for this discussion).

The docs for both React and Redux are open for PRs. If you feel that we need to have sections that better lay out the pros, cons, and reasons to use React and Redux, please submit a PR and we can figure out the best solution from there.

Re: My struggle to learn React

#159
post #61
post #12

This is a fine article. But I just want to say, as an alternate data point, my experience has been exactly the opposite . I love React. React is the first front-end technology I have ever managed to get to stick. * ES6 is just a detail, I know. But for me, ES6 transforms Javascript from an idiosyncratic scripting language where I constantly have to look up the ordinary way to handle basic programming tasks into somet…

Some unsolicited advice from someone who has also been down a similar path. I normally suggest eschewing the javascript class model in favor of using stateless functional components.[0] I've found them simpler to understand and it cuts down on unnecessary typing. I almost never use 'this' in javascript, and instead have favored an OLOO[1] or pure functional style as it fits into a simpler mental model for how things…

>I normally suggest eschewing the javascript class model in favor of using stateless functional components.

So I do this whenever possible, but the way this advice is worded (both here and often in the wild) makes it sound like you can just use them everywhere.

Most UIs have state. I can't imagine a UI that doesn't. Every third component or so I write I end up using classes for, so I've got a mix of classes and functional components throughout the codebase. Do you _never_ use classes? If so, what do you do instead? Otherwise if you're like me, you get to use functional components occasionally which is nice, but are nowhere near being able to get rid of the class syntax.

Re: My struggle to learn React

#160
post #91
post #69

Earlier quoted context omitted.

Let me add a different point of view. The adoption of React in the world of ClojureScript was pretty much instantaneous and total. I don't think anybody writes ClojureScript webapps in any other way these days. But the way React is used is different: it's used as a smarter mapping from application state to DOM. Clojure and ClojureScript programmers already know how to manage state and limit its spread, React (plus th…

Do you have any links/resources for using React with ClojureScript?

Easy 3 step process:

1. Assuming you have leiningen installed, run `lein new figwheel hello-world -- --reagent` and follow the instructions in the output

2. Follow along with https://reagent-project.github.io/

3. Enjoy a nice, refreshing beverage.

Post reply on HN