FieldNotesFORRESTBLADE.COM ↗

2018-10-262 MIN[react][work]

Functionally Speaking

I think it’s been 6 months at Deere now. Training is done, I'm through the probation stuff, and I'm on a small team doing internal tooling. The big project is a migration, there's an old Angular app that dealer teams use and we're rebuilding it in React one screen at a time while the old one keeps running. I know both frameworks well enough now that the job is less about the framework and more about not breaking things people use every day, which is a different skill and nobody teaches it in school.

I was going to write that I've finally mastered React. I actually know it now, class components, the whole lifecycle, when componentDidMount fires, why you don't setState in render, shouldComponentUpdate when a screen gets slow. I've been feeling for a couple months like I made it over some hill. Then yesterday the React team got on stage and announced hooks. There's a video going around of a function component holding state with something called useState, no class, no this, no bind, and the comments are all people either losing their minds with excitement or saying everything we know is obsolete. The difference between now and an year ago is that at least I recognize the feeling this time. It feels like AngularJS all over again.

The thing is though I was talking to one of the senior devs here at Deere about it today and I think I understand why hooks are being worked on. We have components wrapped in three layers of higher order components to share logic and I couldn't tell you what props come from where without reading all three. And nobody who has written this.handleClick = this.handleClick.bind(this) fifty times is going to miss it.

The thing that's actually made me better this year isn't a framework at all. One of senior on my team rejects my pull requests for the same reasons every time, functions doing too many things, names that lie a little, mutating stuff I shouldn't, but also he will ask me why something is the way it is or why it does what it does and if I can’t answer that it gets rejected. It annoyed me for an while and then it started rewiring how I write. I do map and filter and reduce where I used to write loops with counters, I try to keep functions pure so I can test them without setting up half the app, and Redux forced immutability on me. I've been reading Clean Code on lunch breaks and some other stuff like JavaScript the GOOD parts haha. Some of it is preachy but the parts about naming and small functions have paid for the book ten times over. Funny thing is all this functional stuff is exactly the direction React just announced it's going, so maybe Michael has been preparing me for hooks this whole time without either of us knowing.

It's getting cold here. Loki is built for it, I'm not, I’ve never seen weather like this, everyone at work keeps telling me I haven't seen anything yet. I asked if the Mississippi is going to freeze over and everyone says no but I want to walks across it lol.