Skip to content

m-bock/purescript-marionette-react-basic-hooks

Repository files navigation

purescript-marionette-react-basic-hooks

A marionette renderer for react-basic-hooks. Provides an easy to use useMarionette hook.

If you're using react-basic-hooks but you like the way state is handled in halogen components this library may be interesting for you.

Documentation

Installation

spago install marionette spago install marionette-react-basic-hooks 
spago install react-basic-hooks spago install react-basic-dom spago install react-basic 

Short Example

type State = Int type Msg = CountUp | Done control = case _ of CountUp -> do modify_ (_ + 1) liftAff $ delay (Milliseconds 1000.0) modify_ (_ + 1) sendMsg Done Done -> pure unit mkApp :: Component {} mkApp = component "App" \_ -> React.do state /\ act <- useMarionette { initialState: 0 , controller: mkController myControl } pure $ R.div' [ R.div' [ text $ show state ] , R.button { onClick: handler_ $ act CountUp } ]

Full Examples

You can run the examples in this repo with:

spago build yarn install 

And then e.g.:

yarn parcel assets/CountDown.html