Skip to content

nfq-eta/react-router4-with-layouts

Repository files navigation

react-router4-with-layouts

Allow Router to have layout prop with typescript definitions

NPM build

Install

yarn add react-router4-with-layouts

Usage more info

import React, { Component } from 'react';
import { Route } from 'react-router4-with-layouts';
import { Router, Switch } from 'react-router-dom';
import { createBrowserHistory } from 'history';

import { DefaultLayout } from './layouts/DefaultLayout';
import { HomePage } from './pages/HomePage';
import { LoginPage } from './pages/LoginPage';
import { EmptyLayout } from './layouts/EmptyLayout';

const history = createBrowserHistory();

export default class App extends Component {
  render () {
    return (
      <Router history={history}>
        <Switch>
          <Route path="/" component={HomePage} exact layout={DefaultLayout} />
          <Route path="/login" component={LoginPage} layout={EmptyLayout} />
        </Switch>
      </Router>
    );
  }
}

Todo:

  • Add tests
  • Refactor example and use StoryBook
  • Add travis to publish new releases
  • Add changelog

License

MIT © Vytenis Kučiauskas

NOTE Thanks to react-modern-library-boilerplate