2k 大小的 react 路由,替代 react-router,让移动端飞快

3,428 阅读1分钟

It has a similar and simple features for react-router,react-rainie-router is a fast, 2kb alternative to react-router.

react-rainie-router provides a component that conditionally renders its children when the URL matches their path. It also automatically wires up elements up to the router.

  • It is only 2k!, We only use our frequently used functions. Including Route Mathing, Nesting, default routing, Link, dynamic routing...
  • We can delay or prevent routing navigate by listenBefore before routing jump to another. And listenBefore should return a promise object.
  • It's no limit to the number of Router component nested other component.
  • Support coding Spliting by getComponent from Route component.
  • It does not depend on history, but using html5 history API.

Using npm:

$ npm install react-rainie-router --save

The following guide assumes you have some sort of ES2015 build set up using babel and/or webpack/browserify/gulp/grunt/etc.

import  React from 'react';
import ReactDOM from 'react-dom';
import Router, { Link, listenBefore, Route } from 'react-rainie-router';

Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issues or feature request, participate in discussions, upvote or downvote the issues you like or dislike.