Created
December 18, 2018 00:22
-
-
Save frekw/2a6f5033f32f1bcfe179b248261cd205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type timerID; | |
[@bs.val] external setInterval: (unit => unit, int) => timerID = "setInterval"; | |
[@bs.val] external clearInterval: timerID => unit = "clearInterval"; | |
module Counter = { | |
let component = ReasonReact.component("Counter"); | |
let make = (~initial = 0, _children) => { | |
...component, | |
render: _self => { | |
let (count, setCount) = ReactHooks.useState(initial); | |
ReactHooks.useEffectWithoutDependencies(() => { | |
setInterval(() => setCount(. count + 1), 1000) |> ignore; | |
None | |
}); | |
<box width="50%" height="50%"> | |
{ReasonReact.string({j|Count: $count|j})} | |
</box> | |
}, | |
} | |
} | |
let screen = Blessed.screen(~smartCSR = true, ()) | |
ReactBlessed.render(<Counter />, screen) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment