use-router-hook
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

useRouter

使用方式

function RouterComponent(){
    const [history, OutLet] = useRouter({
    routes: [
      {
        pathname: '/home',
        component: Home
      },
      {
        pathname: '/about',
        component: About
      }
    ]
    callbacks: [...callbacks],
    initialPath:  '/home',
  });

  return <>
    <menu>
      <button onClick={()=>history.back()}><</button>
      <button onClick={()=>history.push('/home')}>Home</button>
      <button onClick={()=>history.push('/about')}>About</button>
      <button onClick={()=>history.forward()}>></button>
    </menu>
    <OutLet/>
  </>
}

use-router

use-router

Readme

Keywords

none

Package Sidebar

Install

npm i use-router-hook

Weekly Downloads

3

Version

2.0.5

License

ISC

Unpacked Size

35.5 kB

Total Files

18

Last publish

Collaborators

  • liuze0304