2.1.8 • Published 7 months ago

react-router-gallery v2.1.8

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

React Router Gallery

Supported

react-router-dom@^6.2.2

Install

npm i react-router-dom react-router-gallery --save
yarn add react-router-dom react-router-gallery

Define history

src/history.js

import { createBrowserHistory } from "history";

const history = createBrowserHistory();

export default history;

Usage

src/App.js

import Gallery, { GalleryRouter, GalleryRoutes } from "react-router-gallery";
import { Link } from "react-router-dom";
import history from "./history";
import "react-router-gallery/lib/style/index.scss";
// or use css
// import "react-router-gallery/lib/style/index.css";

const Home = () => {
    return (
        <Gallery>
            Home
            <Link to={{ pathname: "/profile" }} state={{ gallery: true }}>
                Go to profile page
            </Link>
        </Gallery>
    );
};

const Profile = () => {
    return (
        <Gallery>
            Profile
            <Link to={{ pathname: "/" }} state={{ gallery: true }}>
                Go to home page
            </Link>
        </Gallery>
    );
};

const routes = [
    {
        name: "home",
        element: Home,
        path: "/",
    },
    {
        name: "profile",
        element: Profile,
        path: "/profile",
    },
];

const App = () => {
    return (
        <GalleryRouter history={history}>
            <GalleryRoutes routes={routes} />
        </GalleryRouter>
    );
};

export default App;
2.1.8

7 months ago

2.1.7

7 months ago

2.1.6

2 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.5

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago