1.0.1 • Published 10 months ago
@zs-repo/react-router v1.0.1
@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
10 months ago
1.0.0
10 months ago
0.0.13
10 months ago
0.0.14
10 months ago
0.0.15
10 months ago
0.0.10
10 months ago
0.0.11
10 months ago
0.0.12
10 months ago
0.0.9
10 months ago
0.0.8
10 months ago
0.0.7
10 months ago
0.0.6
10 months ago
0.0.5
10 months ago
0.0.4
10 months ago
0.0.3
10 months ago
0.0.2
10 months ago
0.0.1
10 months ago