Components

WithMember

WithMember()

Constructor

new WithMember()

This is a render props component which will call your callback with the current logged in member. It will automatically call /api/v1/members/me to figure out if you are logged in, and replace the contents in the store and callback. In future, this may use LocalStorage to cache the member for some time.

The render will also be passed a function to call for logging out, and another to force the library to check if the member is now logged in.

On initial load, the isLoading prop will be set, which will become false when the user is loaded. Use this field to avoid showing a Login Button while fetch is happening.

In order to update the current member, call checkForMemberUpdated.

Example

import { WithMember } from '@quintype/components';

function MyView({ member, logout, checkForMemberUpdated }) {
  return member ? <div>{member.name} <a onClick={logout}>Logout</a></div> : <div>Please Login!</div>;
}

<WithMember>
  {({ member, logout, isLoading }) => (
    <MyView member={member} logout={logout} isLoading={isLoading} />
  )}
</WithMember>
PropTypes:
Name Type Required Description Default
children func Yes

View Source components/with-member.js, line 82