react
/
0.0.0-this-version-will-be-set-from-ci
react 0.0.0-this-version-will-be-set-from-ci
Install from the command line:
Learn more about npm packages
$ npm install @atomic-router/react@0.0.0-this-version-will-be-set-from-ci
Install via package.json:
"@atomic-router/react": "0.0.0-this-version-will-be-set-from-ci"
About this version
React bindings for atomic-router
Install core and react bindings:
npm i atomic-router atomic-router-react
Don't forget about peer dependencies, if you haven't installed them yet:
npm i effector effector-react react
Wrap your app into this:
import { createHistoryRouter } from 'atomic-router'
import { RouterProvider, Route } from 'atomic-router-react'
import { HomePage } from './routes'
const router = createHistoryRouter({ routes });
const App = () => {
return (
<RouterProvider router={router}>
<Route route={homeRoute} view={HomePage} />
</RouterProvider>
);
};
Simple usage:
import { createRoute } from 'atomic-router'
import { Link } from 'atomic-router-react'
const homeRoute = createRoute<{postId:string}>()
const postRoute = createRoute<{postId:string}>()
<Link to={homeRoute}>Route link</Link>
<Link to={postRoute} params={{ postId:1 }}>Route link with params</Link>
<Link to="https://example.com">External link</Link>
All params:
import { Link } from 'atomic-router-react'
<Link
to={route}
params={{ foo: 'bar' }}
query={{ bar: 'baz' }}
activeClassName="font-semibold text-red-400"
inactiveClassName="opacity-80"
/>
import { Route } from 'atomic-router-react'
<Route route={homeRoute} view={HomePage} />
import { useLink } from 'atomic-router-react'
import { createRoute } from 'atomic-router'
// example path: /some/route/:someId
const someRoute = createRoute<{ someId: number }>()
function SomeComponent() {
const path = useLink(someRoute, { someId: 1 })
// -> /some/route/1
}
Be sure, route is passed into routes
for createHistoryRoutes
.
Else hook will throw [useLink] Route not found
.
Details
- react
- atomic-router
- over 2 years ago
- MIT
- 36 dependencies
Assets
- react-0.0.0-this-version-will-be-set-from-ci-npm.tgz
Download activity
- Total downloads 1
- Last 30 days 0
- Last week 0
- Today 0