A HOC for building a switch or checkbox to toggle a canary cookie.
- Install by executing
npm install react-cookie-switchoryarn add react-cookie-switch. - Import by adding
import CookieSwitch from "./CookieSwitch";. - Use by adding
<CookieSwitchcookieName="canary"><inputid="canary"name="canary"type="checkbox"></input><labelhtmlFor="canary">use of our canray version</label></CookieSwitch>A minimal demo page can be found as storybook
npm run storybook
Add react-cookie-switch to your project by executing npm install react-cookie-switch or yarn add react-cookie-switch.
Here's an example of basic usage:
importReact,{useEffect,useState}from"react";importClockfrom"react-cookie-switch";functionMyApp(){return(<CookieSwitchcookieName="canary"><inputid="canary"name="canary"type="checkbox"></input><labelhtmlFor="canary">use of our canray version</label></CookieSwitch>);}| Prop name | Description | Default value | Example values |
|---|---|---|---|
| cookieName | Cookie name | n/a |
|
| attribute | The attribute set to the children elements | checked |
|
| activated | Value of the attribute and cookie if active | true |
|
| deactivated | Value of the attribute and cookie if not active | false |
|
The MIT License.