Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import React, { PropTypes } from 'react';
  2.  
  3. export default function(Component, props, stubs) {
  4. function RouterStub() {}
  5.  
  6. Object.assign(RouterStub, {
  7. makePath() {},
  8. makeHref() {},
  9. transitionTo() {},
  10. replaceWith() {},
  11. goBack() {},
  12. getCurrentPath() {},
  13. getCurrentRoutes() {},
  14. getCurrentPathname() {},
  15. getCurrentParams() {},
  16. getCurrentQuery() {},
  17. isActive() {},
  18. getRouteAtDepth() {},
  19. setRouteComponentAtDepth() {}
  20. }, stubs);
  21.  
  22. return class Wrapped extends React.Component {
  23. static childContextTypes = {
  24. router: PropTypes.func,
  25. routeDepth: PropTypes.number
  26. }
  27.  
  28. getChildContext() {
  29. return {
  30. router: RouterStub,
  31. routeDepth: 0
  32. };
  33. }
  34.  
  35. render() {
  36. return React.createElement(Component, props);
  37. }
  38. }
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement