Mikko Vataja on Clojure

Shadow-cljs Example: Replacing React with Preact for Smaller Bundle Size

A while back I came across Preact, which advertises itself as "Fast 3kB alternative to React with the same modern API". I thought I'd try it out with ClojureScript, shadow-cljs and reagent. Let's start out with shadow-cljs browser quickstart template. After cloning the repo, we need to install preact: $ npm

Reagent views and multimethods

TL;DR: no form-2 or form-3 components as multimethods: ;; Don't do: (defmethod page :hello [args] (setup-something! args) (fn [_] [:div "hello"])) ;; Do instead: (defn hello-view [args] (setup-something! args) (fn [_] [:div "hello"])) (defmethod page :hello [args] [hello-view args]) When creating multiple pages with the same layout (main navbar, static footer etc), a

Array with drawn values, part 2

I did some code updates for the earlier post. The examples over there are already running the updated code. Since the code listings in that post are no longer up-to-date, let's go through the changes. Better visibility with dark mode - fillRect with white color instead of clearRect: (.clearRect ctx

Bug in ClojureScript 'rem' with JavaScript numbers

(The ClojureScript version used in this post was "1.11.60") TL;DR: > (rem num 1000) ;; should be between -999 and 999 for all integers 6.1897001964269014E26 I wanted to create a simple Reagent toy example where a user can input a number and the number is displayed in words.

Array with drawn values

There are plenty of libraries for visualizing data such as chart.js and highcharts. I'd like to have a version where I can see the contents of an array as an xy-plot that is also drawable i.e. I want to change the values of the array by drawing with

Mikko Vataja on Clojure © 2026