custom-history
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

custom-history

Custom hash history implemenation for preact

INSTALL

npm i -S custom-history

USAGE

import { Router, Link } from 'preact-router';
import { h, render } from 'preact';
import { createHashHistory } from 'custom-history';
 
const Home = (props) => <p>Home</p>;
const About = (props) => <p>About</p>;
const Search = (props) => <p>Search {JSON.stringify(props)}</p>;
 
const App = () => <main>
    <div>
        | <Link href="/home">link home</Link> |
        | <a href="#/home">home</a> |
        | <a href="#/about">about</a> |
        | <a href="#/search/query?x=1">search</a> |
    </div>
    <Router history={createHashHistory()}>
        <Home path="/" />
        <Home path="/home" />
        <About path="/about" />
        <Search path="/search/:query/:advanced?" />
    </Router>
</main>;
 
render(<App />, document.body);

CHANGELOG

See CHANGELOG

TODO

  • Move to jest, ts-jest

Package Sidebar

Install

npm i custom-history

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • iamthes