How to use the react-router-dom.Route.propTypes function in react-router-dom

To help you get started, we’ve selected a few react-router-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github go-faast / faast-web / src / app / components / ModalRoute.jsx View on Github external
import PropTypes from 'prop-types'
import { compose, setDisplayName, setPropTypes, defaultProps, withHandlers, mapProps } from 'recompose'
import { connect } from 'react-redux'
import { push, replace, goBack } from 'react-router-redux'
import { Route } from 'react-router-dom'
import { pick } from 'lodash'

export default compose(
  setDisplayName('ModalRoute'),
  setPropTypes({
    closePath: PropTypes.string, // Path to redirect to on model close
    ...Route.propTypes
  }),
  defaultProps({
    closePath: null, // closePath === null -> history goBack on close modal
  }),
  connect(null, {
    routerPush: push,
    routerReplace: replace,
    routerGoBack: goBack
  }),
  withHandlers({
    render: ({ routerPush, routerReplace, routerGoBack, closePath, component, render }) => (props) => {
      //  takes precedence over  so don’t use both in the same 
      if (component) { return undefined }
      const toggle = (e, replace) => closePath
        ? (replace === true ? routerReplace(closePath) : routerPush(closePath))
        : routerGoBack()
github physiii / open-automation / src / views / components / ScreenRoute.js View on Github external
if (Component) {
								return ;
							} else if (typeof render === 'function') {
								return render(contentProps);
							}
						}} />
					
				);
			}} />
		);
	}
}

ScreenRoute.propTypes = {
	...Route.propTypes,
	path: PropTypes.string.isRequired,
	title: PropTypes.string,
	isContextRoot: PropTypes.bool
};

export default ScreenRoute;
github sensu / sensu-go / dashboard / src / lib / component / util / ConditionalRoute.js View on Github external
import React from "react";
import PropTypes from "prop-types";
import { Route } from "react-router-dom";

class ConditionalRoute extends React.PureComponent {
  static propTypes = {
    ...Route.propTypes,
    component: PropTypes.func,
    render: PropTypes.func,
    redirectPath: PropTypes.string,
    active: PropTypes.bool,

    fallbackRender: PropTypes.func,
    fallbackComponent: PropTypes.func,
  };

  static defaultProps = {
    component: undefined,
    render: undefined,
    active: false,
    redirectPath: "/",
    fallbackRender: undefined,
    fallbackComponent: undefined,
github sujinleeme / reactnd-project-readable / readable / src / Utils / react-router-patch.js View on Github external
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import pathToRegexp from 'path-to-regexp'
import qs from 'qs';

import {
  Route as ReactRouterRoute,
  Link as ReactRouterLink,
} from 'react-router-dom';

export class Route extends Component {
  
  static displayName = 'PatchedRoute';
  
  static propTypes = {
    location: ReactRouterRoute.propTypes.location,
  }
  
  static contextTypes = {
    router: ReactRouterRoute.contextTypes.router,
  }
  
  render() {
    let location = this.props.location || this.context.router.route.location;
    if (location && location.search && location.search.length > 1) {
      location = { ...location };
      location.query = qs.parse(location.search.substring(1));
    }
    return 
  }
}
github go-faast / faast-web / src / app / components / ModalRoute.jsx View on Github external
mapProps((props) => ({
    ...pick(props, Object.keys(Route.propTypes)),
  })),
)(Route)