Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeromake/zreact-router
fork from developit/preact-router
https://github.com/zeromake/zreact-router
Last synced: about 1 month ago
JSON representation
fork from developit/preact-router
- Host: GitHub
- URL: https://github.com/zeromake/zreact-router
- Owner: zeromake
- License: mit
- Created: 2018-05-25T04:03:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T06:16:11.000Z (almost 6 years ago)
- Last Synced: 2024-08-10T07:26:42.257Z (5 months ago)
- Language: TypeScript
- Size: 155 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# zreact-router
[![Travis Build Status](https://travis-ci.org/zeromake/zreact-router.svg?branch=master)](https://travis-ci.org/zeromake/zreact-router)
[![Coverage Status](https://coveralls.io/repos/github/zeromake/zreact-router/badge.svg?branch=master)](https://coveralls.io/github/zeromake/zreact-router?branch=master)a simple router support react, preact, zreact.
copy from [preact-router](https://github.com/developit/preact-router)
## add support
1. animate support([preact-animate](https://github.com/zeromake/preact-animate))
``` jsx
import Animate from "preact-animate";
import { Route, DRouter } from "zreact-router";
function RootRouter() {
return
Home
Test
Home}
path="/"
transitionName={{ enter: "fadeInLeft", leave: "fadeOutLeft" }}
>
Test}
path="/test"
transitionName={{ enter: "fadeInRight", leave: "fadeOutRight" }}
>
;
}
````Router` children not support other tag
``` jsx
import { Router, Link } from "zreact-router";
function RootRouter() {
const Home = () =>Home
;
const Test = () =>Test
return;
Home
Test
}
```
2. hash router support``` jsx
import { Router, Link, LocationProvider, createHashSource, createHistory } from "zreact-router";
const source = createHashSource();
const history = createHistory(source, {mode: "hash"});function RootRouter() {
const Home = () =>Home
;
const Test = () =>Test
return
Home
Test
;
}
```
3. delete global `navigate` export
``` js
import { globalHistory, createHashSource, createHistory } from "zreact-router";// global `navigate`
const { navigate } = globalHistory;// other global `navigate`
const hashHistory = createHistory(createHashSource());
const { navigate } = hashHistory
```4. `Link` support `href` replace
``` jsx
import { Link } from "zreact-router";const HomeLink = Home;
// href be equal to
const HomeLink = Home;
```5. `Route` path params not assign `props` set on `props.params`
``` jsx
import { Router, Link } from "zreact-router";
function RootRouter() {
const Home = () =>Home
;
const Test = (props) =>{"Test: " + JSON.stringify(props.params)}
return;
Home
Test
}
```6. add `location.searchParams`
``` jsx
import { Router, Link } from "zreact-router";
function RootRouter() {
const Home = () =>Home
;
const Test = (props) =>{"Test: " + props.location.searchParams.get("test")}
return;
Home
Test
}
```