How to use the react-router-dom/withRouter 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 meetup / meetup-web-platform / packages / mwp-toaster / src / ToastContainer.jsx View on Github external
location: PropTypes.object.isRequired, // provided by `withRouter`
	history: PropTypes.object.isRequired, // provided by `withRouter`
	match: PropTypes.object, // provided by `withRouter`
	staticContext: PropTypes.object, // provided by `withRouter`
};
ToastContainer.defaultProps = {
	readyToasts: [],
	sysmsgs: {
		sysmsg: {}, // e.g. ?sysmsg=account_suspended
	},
};

export default connect(
	mapStateToProps,
	mapDispatchToProps
)(withRouter(ToastContainer));
github strues / boldr / src / shared / scenes / Admin / Media / VisibleMedia.js View on Github external
import { connect } from 'react-redux';
import withRouter from 'react-router-dom/withRouter';
import {
  getMediaType,
  toggleMedia,
  deleteMedia,
  selectMedia,
} from '../../../state/modules/media';
import Media from './Media';

const mapStateToProps = (state, filter = 'all') => ({
  media: getMediaType(state, filter),
});

const VisibleMedia = withRouter(
  connect(mapStateToProps, { toggleMedia, selectMedia, deleteMedia })(Media),
);

export default VisibleMedia;
github strues / boldr / src / shared / scenes / Admin / Post / PostList / VisiblePostList.js View on Github external
import { connect } from 'react-redux';
import withRouter from 'react-router-dom/withRouter';
import { getPublishedPosts } from '../../../Blog/state';
import PostList from './PostList';

const mapStateToProps = state => ({
  posts: getPublishedPosts(state, 'all'),
});

const VisiblePostListing = withRouter(connect(mapStateToProps)(PostList));

export default VisiblePostListing;
github meetup / meetup-web-platform / packages / mwp-router / src / SyncContainer.jsx View on Github external
render() {
		return this.props.children;
	}
}

SyncContainer.propTypes = {
	children: PropTypes.element.isRequired,
	dispatchLocationChange: PropTypes.func.isRequired,
	location: PropTypes.object.isRequired,
	history: PropTypes.object.isRequired,
};

export default connect(
	null,
	mapDispatchToProps
)(withRouter(SyncContainer));
github Amin52J / React-Redux-Enterprise / app / hoc / cleanOnUnmount / index.js View on Github external
export default function(WrappedComponent, actions, state) {
  const Component = reduxConnect(WrappedComponent, actions, state);

  class Enhancer extends Component {
    componentWillUnmount() {
      this.props.reset();
      if (super.componentWillUnmount) {
        super.componentWillUnmount();
      }
    }
  }

  return withRouter(reduxConnect(Enhancer, hocActions));
}
github strues / boldr / src / shared / scenes / Blog / PostListing / VisiblePostListing.js View on Github external
import { connect } from 'react-redux';
import withRouter from 'react-router-dom/withRouter';
import { getPublishedPosts, getFeaturedPosts } from '../state/posts/reducer';
import PostListing from './PostListing';

const mapStateToProps = state => ({
  features: getFeaturedPosts(state, 'featured'),
  posts: getPublishedPosts(state, 'published'),
});

const VisiblePostListing = withRouter(connect(mapStateToProps)(PostListing));

export default VisiblePostListing;
github kremalicious / portfolio / src / layouts / index.js View on Github external
)
}

TransitionHandler.propTypes = {
  children: PropTypes.any,
  location: PropTypes.object.isRequired,
}

TemplateWrapper.propTypes = {
  children: PropTypes.func,
  data: PropTypes.object.isRequired,
  location: PropTypes.object.isRequired,
}

export default withRouter(TemplateWrapper)

export const query = graphql`
  query metaQuery {
    dataJson {
      title
      tagline
      description
      url
      social {
        Email
        Blog
        Twitter
        GitHub
        Dribbble
      }
      availability {
github trajano / reactjs-admin / src / framework / Navbar.jsx View on Github external
title={this.props.title}
            aria-haspopup="true"
            aria-expanded={this.state.open}>]
        if (this.state.open) {
            dropdownContents.push(<div aria-labelledby="{this.lastUniqueId()}">
                {this.props.children}
            </div>)
        }

        return 
            {dropdownContents}
        
    }
}

const Dropdown = withRouter(onClickOutside(InternalDropdown))

class DebugIcon extends React.PureComponent {
    render() {
        if (this.props.show) {
            return <li><a>
                <span>sm</span>
                <span>md</span>
                <span>lg</span>
                <span>xl</span>
            </a></li>
        } else {
            return null
        }
    }
}