Skip to main content

Posts

Showing posts from January, 2019

Using a React Context as a Dispatch Replacement

React Contexts are the pretty little bows of the React world. Here's a really quick example of the kind of messy code you can cleanup by using contexts, without dragging in a larger dependency like Redux or even Flux. Starting backwards with a diff showing lines of code I was able to remove: All the properties I was able to remove were just pass-through. The Carousel component didn't care about any of them, but it had to pass through these callbacks so the multiple TaskList components inside the carousel could invoke actions. They were removed from the Component class itself, too, since it no longer needed to pass them through. Where did they all go? My ActionContext removed all the need for these passthroughs by providing a single simple helper method, action(), that components rendered under it can access.   I really enjoy the pattern of passing a single callback through a context and removing what used to be lots of callback properties. Of course, I cou

Cheqee: Or, How to Write and Publish a Mobile App In a Couple of Hours for Free for Anyone

For the first time in a long time I wanted to write a brand new little app, from scratch, just for fun. I was feeling the Joy of Coding coming back after a long hiatus. So, yay for me? Yay for me. The idea for a single-case app for the kinds of repeating chores of the day has been knocking around in my head, so I whipped out npx create-react-app and tinkered on my laptop while watching TV. In about an hour and a half I made Cheqee , the Simple app for the things you do every day. I was thrilled to be reminded of how quickly an entirely new application can be built from scratch and published as a PWA (Progressive Web App) and "installed" on any phone and used like any app by anyone around the world, so here's the things I accomplished in just a couple hours total and in this post all the pieces that went into making that happen so effortlessly: Wrote a brand new app that does a simple job, built quickly but easy to expand and improve Incorporated persistent da