Musings on web, technology, worklife and more.

  • Mocking WP_Http in WordPress PHP Unit tests

    If you write automated tests for your PHP code (and you should try!) you’ll often find yourself needing to mock/stub calls to pieces of code that are not under test. With WordPress, our unit tests tend to be more akin to integration/functional tests where we’re testing that several pieces of interrelated code work well when … Continued

  • Automatically delete your Amazon Alexa voice recordings

    Many of your will have a version of Amazon’s Alex home voice assistant speaker (aka “smart speaker”). You’re also probably aware that Amazon records a lot of what you say to Alexa – nearly everything in fact! If you are even remotely security conscious or concerned about your privacy you’d probably rather avoid this happening. … Continued

  • Higher Order Reducers in Redux

    As you may already be aware, a high order function is a function that operates on another function and returns a new function. This is a type of functional composition. If you’ve used Redux for sometime you will also be aware that Reducers are simply functions which accept state and an action and return a … Continued

  • What is Middleware in Redux?

    In a previous article I wrote about how Redux stores provide a dispatch function to “send” action objects to the reducer in order to update the store’s state. But what if we want to do something before or after each and every dispatch such as logging, centralised error handling or allowing dispatch to handle action … Continued

  • Learn Redux by implementing your own Store

    I recently (re)watched Dan Abrmov’s series on Learning Redux and used it to re-create my own Redux store from scratch with tests.

  • When to use React.useCallback()

    I write a lot of React components which require code review. Many times during that process someone has dropped the classic line: I think we should wrap this function in useCallback for performance reasons. But what is useCallback and when does it make sense to use it? useCallback refresher To recap, useCallback is a React … Continued

  • Building a standalone block editor in WordPress using Gutenberg

    A few month’s ago I merged a PR to Gutenberg Core for a new documentation tutorial called Building a custom block editor. The tutorial was originally produced for my own learning, but I was encouraged to add it to the official documentation by members of the Gutenberg core team and the WordPress community. The tutorial … Continued

  • Learning the React Context API

    I have to admit, I’ve never fully taken the time to learn React Context API. Sure I’ve “used” it, but it’s always been me skirting around the edges of existing code. This post puts an end to that. I’ll walk through the basics of what I’ve learnt and how to put it into practice in … Continued

  • Avoiding React component re-renders with React.memo

    Used properly, React.memo can help avoid unnecessary re-renders. Learn how to apply it correctly.

  • Some contributions to the Gutenberg Core Navigation Block

    Over the past few months, the team I work in at Automattic were allocated to spend some time improving the experimental Navigation block in Gutenberg Core. This is how I was able to help.