score:0

class PrivateRoute extends Component {
  render() {
    if (this.props.data.loading) {
      return <Loading />;
    } else if (this.props.data.user) {
      return (
        <div>
          <VerticalNavFixed />
          <article className="docs-content">
            <Switch>
              <Route path="/people/:id" render={(props) => {return React.cloneElement(<Person />, {user: this.props.data.user, ...props})}} />
            </Switch>
          </article>
        </div>
      );
    }
    return <Redirect to={{ pathname: '/login', state: { from: this.props.location } }} />;
  }
}


const PrivateRouteContainer = graphql(userQuery, { options: { fetchPolicy: 'network-only' } })(withRouter(PrivateRoute));

score:3

export const PersonWithData = graphql(PersonQuery, {
  options: ownProps => ({ variables: { id: ownProps.match.params.id } }),
})(Person);

Related Query

More Query from same tag