1.0.2 • Published 5 years ago

rout3r v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago