OCaml JSX for ReasonReact.
yarn add -D ppx_bsx
or npm i --save-dev ppx_bsx
"ppx-flags": ["./node_modules/ppx_bsx/bin/ppx_bsx.exe"]
to bsconfig.json
👉 https://github.com/cxa/ppx_bsx_example
This is how it feel:
[%bsx "
<Container>
<h1>Nice example</h1>
<nav className="(styles "sidebar")">
<Router.Route path='/' component="sidebar" />
</nav>
<div className="(styles "content")">
<Router.Switch>"(mk_switches link_groups)"</Router.Switch>
</div>
</Container>
"]
ReasonReact.stringToElement
, (surprisedly) <div>Hello, World</div>
is acceptedFor non-ascii string, you can simply use string literal like {|ä¸æ–‡|}
, ppx_bsx
will convert to {j|ä¸æ–‡|j}
automatically.