LeanReactSource on GitHub ↗

Example 01 / Try it

A little Lean. A real button.

Click the button. Each click updates state in a Lean component, rendered by React.

Live componentLEAN + REACT

Try a few clicks. Reload the page to start again.

From the blog post.lean
import LeanReact
open LeanReact

structure CounterProps where
  label : String

def Counter : Component CounterProps := component fun props => do
  let count ← useState 0 "count"
  pure <| DOM.button {
    onPress := some (count.modify (fun value => value + 1))
  } #[
    text (props.label ++ ": " ++ toString count.value)
  ]

The button is the Counter component from the post. Its click handler adds one to the current count.