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? Please donate!

donate via btc or eth

btc: 18jCzwsZDGQYcs6Kyv92pd4683cnnxm1Dd
eth: 0xC285F21Cb271Cb4B3F70c4C47B2f7B26063AF590
paypal: 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