@drawbotics/route

2.0.0 • Public • Published

Route

The main difference this route object has compared to Route is that it accepts two extra props: withProps and basePath.

  • withProps: An object containing extra props to be passed to the rendered route component.
  • basePath: Indicate to the rendered route and the children routes what's the base path of the parent.

Usage

An usage example:

import React from 'react';
import { Route } from '@drawbotics/route';

import MyRouteComponent from '../routes/MyRouteComponent';


class MyComponent extends React.Component {
  render() {
    return (
      <Route
        basePath="/parent-url"
        path="/some-url"
        withProps={{ title: 'The Title', items: [ /* ... */ ]
        component={MyRouteComponent} />
    );
  }
}

Extra

A Switch component with support for basePath is also included. It's used exactly the same way as vanilla Switch from react-router.

/@drawbotics/route/

    Package Sidebar

    Install

    npm i @drawbotics/route

    Weekly Downloads

    1

    Version

    2.0.0

    License

    UNLICENSED

    Unpacked Size

    16.9 kB

    Total Files

    9

    Last publish

    Collaborators

    • manuelitox
    • larsbs
    • nicmosc
    • bartolomeumr
    • leopoldarkham