rout3r

1.0.2 • Public • Published
rout3r

package version package downloads standard-readme compliant package license make a pull request

Trie based React Router in under 1 KB

Table of Contents

About

Install

This project uses node and npm.

$ npm install rout3r
$ # OR
$ yarn add rout3r

Usage

import React from "react";
import ReactDOM from "react-dom";
import { Router, Link } from "rout3r";

const PageOne = () => (
  <h2>
    Page 1 <Link href="/tiaan?hello=person">go to</Link>
  </h2>
);
const PageTwo = props => (
  <h2>
    Page 2 {props.params.ahhhhh} {JSON.stringify(props.searchParams)}
  </h2>
);

const PageThree = props => <h2>Page 3</h2>;

const PageFour = props => <h2>Page 4</h2>;

function App() {
  return (
    <Router defaultPath="/404">
      <PageOne path="/" />
      <PageThree path="/foo" />
      <PageFour path="/foo/bar" />
      <PageTwo path="/:ahhhhh" />
    </Router>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i rout3r

Weekly Downloads

11

Version

1.0.2

License

MIT

Unpacked Size

63.1 kB

Total Files

13

Last publish

Collaborators

  • tiaanduplessis