February 08, 2017

How to Dynamically Render React Components

I am currently working on a React/Redux universally rendered application at work. It has some fun parts and I want to share what I've learned from building them.

One of those parts is a component I have called the BlocksLoop. In the design phase of the project, long before I was ever a part of the…

Categories
JavaScriptWeb Development
Tags
React
January 20, 2017

Loading State Trick for Stateless Functional Components in React

I want to share with you a little trick I've been using lately with stateless functional components in React. This is probably really old news to some of you, but I'm hoping there are a few of you who don't know this one yet.

If you're getting started with React, and especially if you're using Redux…

Tags
React
December 03, 2016

IMHO: Avoid Clever Code

or Code is for Humans, Not for Computers

Yesterday, I was poring through some code when I came across a pattern I hadn't seen used in JavaScript before. The pattern looked like this:

const foo = true // or any value that can be truthy or falsy
const bar = () => {
  console.log('Hey!')
}

// And then later in the code, I found a bunch of one liners like this
foo && bar()

// 'Hey!'

This pattern takes advantage of how logical operators work. In the case of &&, when the left side is true, the runtime evaluates the right side. Since an && requires both sides to be true to return true, it only evaluates and runs the right side if the left side is true. Essentially, the developer…

December 01, 2016

How To Use Client Side Libraries in a Universal JavaScript App

At work, I am building a JavaScript application with universal rendering. There are a number of challenges with building a universally rendered application, but one challenge in particular is making sure code that should only run on the client doesn't cause the server to crash.

Today, I built a React component that used the imagesloaded library to detect if any images nested in the component were loaded. This is very useful for downloading large images. You can set the opacity of the image to 0 until it loads…

Tags
React
November 16, 2016

State Snapshots in Redux

Redux is a predictable state container for JavaScript apps. I've been using it in all of my apps recently and I discovered an elegant and clever use of it that I want to share. The rest of this article assumes you know how to use Redux. If you do not, follow the link above and read up before…

Tags
Redux
July 02, 2016

Componentize Gem

or Bringing Components to Rails Projects.

In my last few Rails projects, I have been exploring strategies to create and utilize "components" similar to how components are used in Ember. Rails doesn't have a simple, native way to do this. However, I think I've come up with a good way to accomplish this, and I have created a gem to facilitate…

Categories
Web Development
Previous123456
7
891011Next