Hjertnes.blog

#

January 16, 2018

Testing out feedbin, it feels like cheating

#

January 16, 2018

Every time I use the portrait mode on my iPhone I end up reaching for my X-Pro 2

Structure

January 16, 2018

A few words on structuring your react app. Don’t think too much about structure, keep it as flat as possible, for as long as possible. Use redux to make your state sane, and use higher order components to limit code duplication. But keep one component per file.

I’m a fan of structuring stuff when it hurts to not do it. Then I would look into making modules out of the stuff that is just used one place.

Let’s say you have a route where you add and edit blog posts; have all the stuff that is just used there in a folder, and then have the main component you use in the Editor in the moduleFolderName/index.js.

React won’t solve any of your problems with sturcturing your code base, but neither will anything else.

But one thing that is more imporant than most is to use eslint. Base it on a sane set of configurations like the airbnb one and modify it to fit your requirements. Linting is a good way to keep your codebase sane and a good way to filter out some stuff.

It won’t replace automated testing or proptypes but is a important addtion.

One last thing I personally think is important to think about when you have a large app, try move everything that is used multiple places to a single place. And then try to make sure that each module in your component structure never import outside of it’s own folder, except for state and common. I also always start with the following structure: state(everything related to redux), utils(javascript code) and components(react code).

#

January 16, 2018

Bye bye productivity — the next 12 hours. I decided to do a fresh install on my MacBook Pro.

Spacemacs

January 15, 2018

There is some confusion about what Spacemacs is for some strange reason. A lot of people seems to believe that it is a fork of Emacs. It might be beause of the writing on their website, that kind of supports that statement. But it is wrong. What Spacemacs is, is rather simple, it is a git repository that is a emacs configuration. It comes with a lot of great features out of the box and it also auto updates. And it also has a special way of configuring your emacs setup.

There are many good things about that. It does make it easier to get started with emacs, because most of what most users want works out of the box, as long you activate the right “layers”. And the way you configure spacemacs also makes it less likely that you end up in “emacs.d bankrupsy.”. Something that we VIM users used to mock emacs users for. It is when you end up in a place where you can’t figure out how to fix your config and have to delete it.

Webpack

January 15, 2018

Webpack is your compiler, and learning how to use that tools shouldn’t be the first thing you do, because a lot of people will probably give up before they get started. I think that most experienced developers should understand what the webpack configuration does. And all teams should have at least one person that can wrangle together a config file from scratch.

I say, start with create-react-app, then learn how to write react code, and then learn how webpack works when you have a thing you need to do that create-react-app can’t do.

It isn’t that complicated really. You have a entry point (the javascript file where webpack will begin) some configuration of how you want to transform your code, some configuration of how the output should be and that’s it. The great thing about using something like webpack is that you can build everything from your javascript code, and styling plus generating HTML files (both for development and production). You can for example add a hash to the file names to avoid caching problems in production.

I typically start with create-react app these days, and then move on to using my own webpack, if or when I need to.

#

January 14, 2018

I’m going to do my best to not make jokes about checks and health care in America this year.

#

January 14, 2018