21 November 2021

React CanvasComponent and Conway’s Game of Life

A few years ago, I was messing around with the HTML Canvas element and 2d rendering context in React and I came up with a very simple component that would let me run a draw function whenever the props updated. Here’s the code on codepen.

For good measure, I included a simple demo implementation of Conway’s Game of Life (which is a zero-player game, so don’t expect to be able to do anything after clicking start):

Conway’s Game of Life

Since I originally wrote this, I’ve been preferring TypeScript over JavaScript and function components + hooks vs class components, so an update might be in order…

Did you find this helpful or fun? paypal.me/mrcoles
comments powered by Disqus

Peter Coles

Peter Coles

is a software engineer living in NYC who is building Superset 💪 and also created GoFullPage 📸
more »

github · soundcloud · @lethys · rss