1.0.1 • Published 8 months ago

@zs-repo/react-router v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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

8 months ago

1.0.0

8 months ago

0.0.13

8 months ago

0.0.14

8 months ago

0.0.15

8 months ago

0.0.10

8 months ago

0.0.11

8 months ago

0.0.12

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago