Build the UI with Reagent

Reagent is more opinionated than React regarding component life cycle. While React is agnostic about the strategy used to trigger component updates; Reagent makes this decision for us. Reagent uses a data-driven approach where components observe the state of reactive atoms. Components just specify the state they’re concerned with, and Reagent handles the life cycle for us. As a result, we typically only need to implement the render functions of our components.

Before we can build our UI, we need to add the Reagent dependency to our project:

 :dependencies
 [...
  [reagent ​"1.0.0"​]]

Since our dependencies have changed, we also need to restart cljsbuild.

 ...
 Successfully compiled "target/cljsbuild/public/js/app.js" ...

Get Web Development with Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.