1.0.2 • Published 4 years ago
@jouddeken/react-router-setup v1.0.2
React Router Setup
Use the react-router-dom package with just a single element to render and a config file.
Prerequisites
- Node
- 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
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')), }, ];
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;