[ Software Engineer ] • 856-419-7654

React pattern for styles using .bind()

3 • 17 • 22 natesymer


Sometimes, it's necessary to write a bunch of React components in one file. Ideally, that's not how it's done, but sometimes (and for some people) this isn't feasible in the initial steps of writing code. Most code I've seen handles styles in one of the following ways:

Way #1

const style = {
    element: { /* ... */ },
    anotherElement: { /* .... */}

const MyComponent = props => {
    return <>
        <div style={style.element} />
        <div style={style.anotherElement} />

Way #2

WordPress & the Web

3 • 27 • 18 natesymer


I don't hate WordPress. Sure, there are aspects of it that suck, but any platform has similar limitations. For most sites, WordPress would be suitable - especially if you intend to do something simple. I'll take a look at performance, security, data organization, and developer productivity.

Any web platform will have performance drains. Scripts have to be loaded, processes need to be loaded into memory, OS calls need to be made, etc. The only platform that I know that doesn't suffer from 66% of those is Haskell (this site is Haskell) because Warp is optimized to use as few OS calls as humanly possible and nothing has to be compiled/loaded at runtime.

© 2017, Nathaniel Symer