Components

WithMember

<WithMember children isBridgekeeperEnabled />

Constructor

# <WithMember children isBridgekeeperEnabled />

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.

In order to make bridgekeeper api calls for the current member and logout, isBridgekeeperEnabled prop needs to set to true. The default value is false.

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
isBridgekeeperEnabled bool No Enabling this prop makes the relevant bridgekeeper calls for checking the member and the logout api false

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