TIP: Set “type” attributes explicitly on <button> elements

File under “Tiny little HTML5 useful tip.”

TL;DR

Apply this habit to all buttons contained within a form. Buttons outside of forms are just
buttons, not form controls.

Continue reading

Advertisements

This week in front end architecture

In a react/redux application:

  • add a checkbox
    in jsx

  • capture its state by setting its vDom state with { [name]: !this.state.checked }
    in a switch statement

  • unit tests are jest snapshot diffs
    in typescript

  • className="bootstrap" or className={style.injection}
    incompatible

Making simple things hard in the front end again.

Two object definition refactorings from 2017

Original gist for this post

Earlier this year a colleague was tasked with modifying an application that defined a very large object (i.e., containing 20+ properties). The troubling part was that the object was entirely defined twice, first in an if-block, then in an else-block, all 20+ properties spelled out in each. That made the differences between the definitions difficult to detect just by scanning.

Continue reading