How to use the found/lib/PropTypes.routerShape.isRequired function in found

To help you get started, we’ve selected a few found 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 staylor / graphql-wordpress / packages / relay-wordpress / src / components / Post / index.js View on Github external
import ContentNode from 'components/ContentNode';
import { dateRegex } from 'utils/regex';
import type { Post as PostType } from 'relay-wordpress';
import PostLink from './PostLink';

type PostProps = {
  post: PostType,
};

/* eslint-disable react/no-danger */

class Post extends React.Component {
  props: PostProps;

  static contextTypes = {
    router: routerShape.isRequired,
  };

  onEmbedClick = () => (e: Event) => {
    e.preventDefault();

    const { id, date } = this.props.post;
    const [, year, month, day] = dateRegex.exec(date);
    const url = `/${year}/${month}/${day}/${id}`;

    this.context.router.push(url);
  };

  render() {
    const { content: { data: content }, excerpt, featuredMedia } = this.props.post;
    const isEmbed = content && content.length && content[0].__typename === 'Embed';
github jkettmann / universal-react-relay-starter-kit / client / pages / UserLogin / UserLogin.js View on Github external
import Wrapper from './Wrapper'
import Bold from './Bold'
import Hint from './Hint'
import FormWraper from './FormWrapper'
import TextInput from '../../components/Input/FormsyText'
import Button from '../../components/Button'

import {
  login as loginUser,
  loginWithFacebookRoute,
} from '../../auth'
import { ERRORS } from '../../../config'

class LoginPage extends React.Component {
  static propTypes = {
    router: routerShape.isRequired,
    viewer: PropTypes.shape({
      isLoggedIn: PropTypes.bool,
    }).isRequired,
  }

  setFormElement = (element) => {
    this.formElement = element
  }

  login = ({ email, password }) => {
    loginUser({ email, password })
      .then((error) => {
        if (error) {
          console.error(ERRORS[error.name])
        } else {
          this.props.router.go(-1)
github 4Catalyzer / found / examples / transition-hook / src / index.js View on Github external
<ul>
        
          Main
        
        Other
      </ul>

      {children}
    
  );
}

App.propTypes = appPropTypes;

const mainPropTypes = {
  router: routerShape.isRequired,
};

class Main extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      transitionType: 'confirm',
      showCustomConfirm: false,
    };

    this.removeTransitionHook = props.router.addTransitionHook(
      this.onTransition,
    );

    this.resolveCustomConfirm = null;
github 4Catalyzer / found-scroll / src / ScrollManager.js View on Github external
import StateStorage from 'farce/lib/StateStorage';
import HttpError from 'found/lib/HttpError';
import { routerShape } from 'found/lib/PropTypes';
import PropTypes from 'prop-types';
import React from 'react';
import ScrollBehavior from 'scroll-behavior';

const STORAGE_NAMESPACE = '@@scroll';

const propTypes = {
  shouldUpdateScroll: PropTypes.func,
  createScrollBehavior: PropTypes.func.isRequired,
  renderArgs: PropTypes.shape({
    location: PropTypes.object.isRequired,
    router: routerShape.isRequired,
    elements: PropTypes.array,
    error: PropTypes.instanceOf(HttpError),
  }).isRequired,
  children: PropTypes.node,
};

const defaultProps = {
  createScrollBehavior: config => new ScrollBehavior(config),
};

class ScrollManager extends React.Component {
  constructor(props, context) {
    super(props, context);

    const { createScrollBehavior, renderArgs } = props;
    const { router } = renderArgs;
github staylor / graphql-wordpress / packages / relay-wordpress / src / containers / App.js View on Github external
settings: Object,
    navMenu: Object,
    sidebar: Object,
  },
  children: any,
  router: any,
};

@IntlProvider
class App extends React.Component {
  static defaultProps = {
    children: null,
  };

  static childContextTypes = {
    router: routerShape.isRequired,
  };

  removeTransitionHook = () =&gt; null;

  constructor(props: AppProps, context: any) {
    super(props, context);

    this.removeTransitionHook = props.router.addTransitionHook(this.onTransition);
  }

  componentWillUnmount() {
    this.removeTransitionHook();
  }

  onTransition = () =&gt; {
    if (typeof window !== 'undefined') {
github jkettmann / universal-react-relay-starter-kit / client / pages / UserPosts / UserPosts.js View on Github external
return <div>
  }

  return (
    <div>
      
    </div>
  )
}

UserPosts.propTypes = {
  router: routerShape.isRequired,
  permission: PropTypes.shape({
    isLoggedIn: PropTypes.bool,
    canPublish: PropTypes.bool,
  }).isRequired,
  posts: PropTypes.shape({
    edges: PropTypes.array,
  }).isRequired,
  hasMore: PropTypes.bool.isRequired,
  loadMore: PropTypes.func.isRequired,
}

const fragments = graphql`
  fragment UserPosts on Query {
    permission {
      isLoggedIn
      canPublish</div>
github staylor / graphql-wordpress / packages / apollo-wordpress / src / components / Post.js View on Github external
export default class Post extends Component {
  static propTypes = {
    post: PropTypes.shape({
      id: PropTypes.string,
      slug: PropTypes.string,
      date: PropTypes.string,
      title: PropTypes.object,
      content: PropTypes.object,
      excerpt: PropTypes.object,
      featuredMedia: PropTypes.object,
    }).isRequired,
  };

  static contextTypes = {
    router: routerShape.isRequired,
  };

  content = null;
  bindRef = node => {
    this.content = node;
  };

  onEmbedClick = () => e => {
    e.preventDefault();

    const { id, date } = this.props.post;
    const [, year, month, day] = dateRegex.exec(date);
    const url = `/${year}/${month}/${day}/${id}`;

    this.context.router.push(url);
  };
github staylor / graphql-wordpress / packages / apollo-wordpress / src / containers / App.js View on Github external
sidebarID: 'U2lkZWJhcjpzaWRlYmFyLTE=',
    },
  },
})
@IntlProvider
export default class App extends Component {
  static propTypes = {
    data: PropTypes.shape({
      viewer: PropTypes.shape({
        settings: PropTypes.object,
        navMenu: PropTypes.object,
        sidebar: PropTypes.object,
      }),
    }).isRequired,
    children: PropTypes.node,
    router: routerShape.isRequired,
  };

  static defaultProps = {
    children: null,
  };

  static childContextTypes = {
    router: routerShape.isRequired,
  };

  constructor(props, context) {
    super(props, context);

    this.removeTransitionHook = props.router.addTransitionHook(this.onTransition);
  }
github staylor / graphql-wordpress / packages / apollo-wordpress / src / containers / App.js View on Github external
viewer: PropTypes.shape({
        settings: PropTypes.object,
        navMenu: PropTypes.object,
        sidebar: PropTypes.object,
      }),
    }).isRequired,
    children: PropTypes.node,
    router: routerShape.isRequired,
  };

  static defaultProps = {
    children: null,
  };

  static childContextTypes = {
    router: routerShape.isRequired,
  };

  constructor(props, context) {
    super(props, context);

    this.removeTransitionHook = props.router.addTransitionHook(this.onTransition);
  }

  componentWillUnmount() {
    this.removeTransitionHook();
  }

  onTransition = () => {
    if (typeof window !== 'undefined') {
      window.scrollTo(0, 0);
    }
github jkettmann / universal-react-relay-starter-kit / client / pages / UserRegister / UserRegister.js View on Github external
import { createFragmentContainer, graphql } from 'react-relay'
import Formsy from 'formsy-react'

import Wrapper from './Wrapper'
import FormWrapper from './FormWrapper'
import TextInput from '../../components/Input/FormsyText'
import Button from '../../components/Button'
import {
  register as registerUser,
  loginWithFacebookRoute,
} from '../../auth'
import { ERRORS } from '../../../config'

class RegisterPage extends React.Component {
  static propTypes = {
    router: routerShape.isRequired,
    viewer: PropTypes.shape({
      isLoggedIn: PropTypes.bool,
    }).isRequired,
  }

  constructor() {
    super()
    this.state = {
      canSubmit: false,
    }
  }

  setFormElement = (element) => {
    this.formElement = element
  }