quave:logged-user

v0.0.1Published 3 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

quave:logged-user

This is a meteor package that creates a context for the logged user. This context contains the loggedUser and loadingLoggedUser fields and the functions refetchLoggedUser and logout.

loggedUser: the logged user on the meteor accounts.

loadingLoggedUser: TRUE when the user is logging in or the refetchLoggedUser is called.

refetchLoggedUser: a function to refetch the logged user when you need to update its data on the client side.

logout: a function to logout the user.

Dependencies

This package has these npm depencies. They're not enforced because this could cause some problems .

  • react
  • @apollo/react-hooks
  • graphql-tag

Installation

meteor add quave:logged-user

Example

1//home.js
2import { useLoggedUser } from 'meteor/quave:use-logged-user/useLoggedUser';
3
4const Home = () => {
5    const { loggedUser } = useLoggedUser();
6    
7    if (loggedUser) {
8        return "You are logged in!!!";
9    }
10    
11    return "Sorry, you need to log in"
12}
13
14//app.js
15import { LoggedUserProvider } from 'meteor/quave:use-logged-user/LoggedUserProvider';
16
17// Use the Form component
18<LoggedUserProvider>
19    <Home/>
20</LoggedUserProvider>