@jouddeken/react-router-setup

1.0.2 • Public • Published

React Router Setup

Use the react-router-dom package with just a single element to render and a config file.

Prerequisites

  1. Node
  2. NPM or Yarn

Installation

Using NPM:

npm install @jouddeken/react-router-setup

Using Yarn

yarn add @jouddeken/react-router-setup

Dependencies

This package requires the following packages:

  • prop-types
  • react
  • react-router-dom

Usage

  1. Create a config file, example:

    import React from 'react'; // used for React.lazy
    
    export default [
      {
        id: 'home',
        path: '/',
        exact: true,
        component: React.lazy(() => import('../path/to/component')),
      },
    ];
  2. Import the required packages and pass in the config as property to the Router component

    import React from 'react';
    import Router from '@jouddeken/react-router-setup';
    import routeConfig from './path/to/config/file';
    
    const App = () => (
      <Router config={routeConfig} />
    );
    
    export default App;

Package Sidebar

Install

npm i @jouddeken/react-router-setup

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

79.9 kB

Total Files

26

Last publish

Collaborators

  • jouddeken