프로젝트
GitHub에서 보기 
zoontek/chicane
소개
React와 TypeScript를 위한 간단하고 안전한 라우터입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Original@zoontek/chicane
A simple and safe router for React and TypeScript.
Design principles
- Typed routes: improving the DX, and making sure all your params are here!
- Component-friendly: the router nicely fits in your React app.
- Easy-to-use: naming routes instead of moving around unsafe URLs.
- Performant: avoids any unnecessary render.
Installation
$ yarn add @zoontek/chicane
# --- or ---
$ npm install --save @zoontek/chicane
Links
- 📘 Documentation
- ⚖️ License
Quickstart
import { createRouter } from "@zoontek/chicane";
import { match } from "ts-pattern";
const Router = createRouter({
Home: "/",
Users: "/users",
User: "/users/:userId",
});
const App = () => {
const route = Router.useRoute(["Home", "Users", "User"]);
// route object is a discriminated union
return match(route)
.with({ name: "Home" }, () => <h1>Home</h1>)
.with({ name: "Users" }, () => <h1>Users</h1>)
.with({ name: "User" }, ({ params }) => <h1>User {params.userId}</h1>) // params are strongly typed
.otherwise(() => <h1>404</h1>);
};
Run the example app
$ git clone [email protected]:zoontek/chicane.git
$ cd chicane/example
$ yarn install && yarn dev
# --- or ---
$ npm install && npm run dev
🙌 Acknowledgements
- react-router for the
historyand theLinkcreation code. - reach-router for the path ranking algorithm.
관련 프로젝트 살펴보기
불러오는 중…