rescript-react-router-dom
v1.0.8
Published
Rescript wrapper for React Router DOM
Downloads
12
Readme
Rescript React Router DOM
Rescript bindings for React Router DOM
Getting Started
- Add this to your
package.json
:
npm i rescript-react-router-dom
- Add this to you
bsconfig.json
:
"bs-dependencies": [
"@rescript/react",
"rescript-react-router-dom"
]
- Import into your Rescript project
open RescriptReactRouterDom.ReactRouterDOM
Example Usage
Router
open RescriptReactRouterDom.ReactRouterDOM
@react.component
let make = () => {
<HashRouter>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="blog" element={<BlogPage />} />
<Route path="blog/:slug" element={<ArticlePage />} />
<Route path="about-me" element={<AboutMePage />} />
<Route path="projects" element={<ProjectsPage />} />
<Route path="*" element={<Error404Page />} />
</Routes>
</HashRouter>
}
Links
open RescriptReactRouterDom.ReactRouterDOM
@react.component
let make = () => {
<div>
<Link className="columns" href={`/blog`}>
{"Blog" |> React.string}
</Link>
</div>
}
- Note:
to
is a reserved word in Rescript. It has been replaced byhref
in this port.