This is a port of @opendevtools/hooks for ReasonML/BuckleScript. This project was initially developed @iteam1337.
npm install @opendevtools/rescript-hooksAdd @opendevtools/rescript-hooks to bs-dependencies in bsconfig.json
useToggle(~initialState: option(bool), unit): (bool, unit => unit)initialState is set to false by default, that's why it's an option(bool)
@react.component
let make = () => {
let (isAlive, toggleValue) = OpenDevToolsHooks.useToggle()
<button onClick={_ => toggleValue()}> {(isAlive ? `🚀` : `😴`)->React.string} </button>
}Gets a value from a specified query param
useQueryParam(~param: Js.Dict.key): string@react.component
let make = () => {
let param = OpenDevToolsHooks.useQueryParam(~param="sweetParam")
<div> {"That's a nice query param with the value " ++ param |> React.string} </div>
}