1.0.1 • Published 9 months ago

@zs-repo/react-router v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@zs-repo/react-router

Based on the ionic framework open source framework for encapsulation, the current library implements a react routing library for forward refresh and backward cache.

Documentation

1. add ActiveRouterProvider

import {
  ActiveRouterProvider
} from "@zs-repo/react-router";
import routes from "./router.js";

function App() {
  return <ActiveRouterProvider routes={routes}/>;
}

export default App;

2. create routes

import About from "./About.jsx";
import Home from "./Home.jsx";
const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/about',
    component: About
  }
];

export default routes

3. navigating in components

import {
  useRouter,
  useViewDidEnter,
  useViewDidLeave,
  useViewWillEnter,
  useViewWillLeave
} from "@zs-repo/react-router";

function Home() {
  const router = useRouter();

  useViewDidEnter(() => {
    console.log('useViewDidEnter event fired');
  });

  useViewDidLeave(() => {
    console.log('useViewDidLeave event fired');
  });

  useViewWillEnter(() => {
    console.log('useViewWillEnter event fired');
  });

  useViewWillLeave(() => {
    console.log('useViewWillLeave event fired');
  });

  return <div>
    <div>Home Page</div>
    <button onClick={() => {
      router.push('/about');
    }}>to About
    </button>
  </div>;
}

export default Home;
1.0.1

9 months ago

1.0.0

9 months ago

0.0.13

9 months ago

0.0.14

9 months ago

0.0.15

9 months ago

0.0.10

9 months ago

0.0.11

9 months ago

0.0.12

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago