Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { PropTypes } from 'react';
- export default function(Component, props, stubs) {
- function RouterStub() {}
- Object.assign(RouterStub, {
- makePath() {},
- makeHref() {},
- transitionTo() {},
- replaceWith() {},
- goBack() {},
- getCurrentPath() {},
- getCurrentRoutes() {},
- getCurrentPathname() {},
- getCurrentParams() {},
- getCurrentQuery() {},
- isActive() {},
- getRouteAtDepth() {},
- setRouteComponentAtDepth() {}
- }, stubs);
- return class Wrapped extends React.Component {
- static childContextTypes = {
- router: PropTypes.func,
- routeDepth: PropTypes.number
- }
- getChildContext() {
- return {
- router: RouterStub,
- routeDepth: 0
- };
- }
- render() {
- return React.createElement(Component, props);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement