Vulcan/packages/vulcan-core/lib/modules/containers/withCurrentUser.js

32 lines
682 B
JavaScript
Raw Normal View History

import React, { Component } from 'react';
2017-03-23 16:27:59 +09:00
import { getFragment } from 'meteor/vulcan:lib';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
2017-01-23 11:00:44 +09:00
const withCurrentUser = component => {
return graphql(
gql`
query getCurrentUser {
currentUser {
...UsersCurrent
}
}
${getFragment('UsersCurrent')}
`, {
2017-01-14 08:29:51 +09:00
alias: 'withCurrentUser',
props(props) {
2018-02-08 12:21:45 +09:00
const { data } = props;
return {
2018-02-08 12:21:45 +09:00
currentUserLoading: data.loading,
currentUser: data.currentUser,
currentUserData: data,
};
},
}
)(component);
}
2017-01-23 11:00:44 +09:00
export default withCurrentUser;