Rackt allows you to develop full-featured React web apps in RacketScript. You can use all React compatible libraries with it as well.
Here you can see an example of a pretty simple Rackt-component:
(define (counter props ..) (define-values (counter set-counter) (use-state 0)) (<el "div" (<el "button" #:props ($/obj [ className "button" ] [ type "button" ] [onClick (lambda (_) (set-counter (- counter 1)))]) "- 1") (<el "span" #:props ($/obj [ className "counter" ]) counter) (<el "button" #:props ($/obj [ className "button" ] [ type "button" ] [onClick (lambda (_) (set-counter (+ counter 1)))]) "+ 1"))) (render (<el counter) "root")
<el is just a simple wrapper for
React.createElement. It has the same API but with a little bit different syntax:
(define create-element (lambda (component #:props [props null] . children) ...
As you can see it takes
props and any amount of
For other functions, you can see their implementation right here and use React documentation for all of them.
You can find working examples on the Rackt's main page.
It's unpublished in the registry for now, so to install the library you should clone the repo and install it manually:
git clone [email protected]:rackt-org/rackt.git cd ./rackt raco pkg install