hjertnes.blog

#

17.01.2018 01:00

Weird thought.

What if Amazon combined their recommendation engine with photo hosting and a dating service?

#

17.01.2018 01:00

I’m not sure if I’m going to re-configure Spark, after my OS X re-install. I’m going to stick with webmail for a while.

Component Design

17.01.2018 01:00

How you design your components will affect a large number of different things, everything from performance to how maintainable your code is. It will never be perfect, and don’t try to get it right form the start. It will just kill your productivity.

Use PureComponent instead of Component as your base class, it will limit the number of re-renders and therefore improve your apps general performance. And learn how to develop using many small components instead of fewer large ones, because then the browser will spend much less resources on rendering. If everything is in one large render function (aka a component) then your browser will run through all of it every time something change, but it will only have to run through a smaller part of it if you have divided it into many smaller components.

Smaller components are also usually easier to make re-usable.

#

16.01.2018 01:00

Top 5 BuJo Ideas in 2017 - Bullet Journal 🤦‍♂️ Write Bullet Journal like every other self respecting adult would.

#

16.01.2018 01:00

“fucking snow…”

#

16.01.2018 01:00

#

16.01.2018 01:00

Testing out feedbin, it feels like cheating

#

16.01.2018 01:00

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

#

16.01.2018 01:00

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

Structure

16.01.2018 01:00

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).