0.0.3 • Published 10 months ago
@sfdl/sf-cookie-gate v0.0.3
Cookie Gate
This is a small React HoC library for gating top level components behind a cookie.
Installation
Install from npm using the package manager of your choice
yarn add @sfdl/sf-cookie-gate
or
npm install @sfdl/sf-cookie-gate
Usage
The application exposes a minimal API. Essentially it is a bi-directional HoC which pushes down one path or another depending on whether a cookie has been set. A cookie handler function is provided for convenience
Prop | Description | Type |
---|---|---|
ApplicationComponent | The component to be shown if the cookie is set | JSX Element or React.lazy Element |
LandingComponent | The component to be shown if the cookie is not set | JSX Element or React.lazy Element |
options | An object of options to configure the cookie | CookieOptions |
CookieOptions
The cookie options object is used to structure and configure the cookie. It has the following key/values
| Key | Value |
|-----|-------|
| cookieName
| cookie name string |
| cookieOptions
| an object of js-cookie options|