G’day legends, today I’ve got two blog posts I wrote in the last couple of months about vastly different topics. Both come out of a new role I’ve taken on with Explosion. The first is about render-as-you fetch with React and Relay, the second is about running VMs on my new M1 Macbook Air.
React, Relay and render-as-you-fetch
So I've been moving an existing React codebase to a GraphQL API over the last few weeks using Relay as the front-end client. One thing I've been struggling with has been implementing the render-as-you-fetch (or fetch-as-you-render) pattern. A big part of the difficulty here is how our tools rely on the render path for coordinating work.
If you haven’t come across the render-as-you-fetch pattern yet it’s pretty interesting. The basic idea is that the render path of your components is a bad place to load data. The simplest reason is that it can be blocked by other components loading. If you only load data on the render path, you can be susceptible to waterfalls of loads. The worst case is one component blocks a number of other components from rendering, then when it unblocks all of those components need to load their own data. Essentially you end up with:
So the alternative is to first start loading your data, and then while it’s loading proceed with rendering. This turns out to be quite a difficult idea to implement, for something that seems so conceptually simple! You can read about it on Dev:
Understanding render-as-you-fetch with Relay
The other thing I wrote about was onboarding with my new M1 Macbook Air. When I bought the M1 Macbook everyone was super positive about everything “just working”. Especially with the Rosetta stuff. The big iffy area was running Docker, but that got resolved and seemed to be working fine, so I bought one. Then I onboarded with this new job and they weren’t using Docker they were using Vagrant… which facilitates running things on a virtual machine. And virtual machines very much do not work on the M1, not even a little bit.
So I proceeded to go about figuring out how to run Vagrant on top of Docker. It was a wild ride and consumed me for like a week. So I wrote about it. You can read that also on Dev:
Running Vagrant on an M1 Apple Silicon using Docker
Hope you’re doing grand out there, keep on trucking or whatever.
Cheers,
Ben