0.1.7 • Published 5 years ago

nine3-cookie-consent v0.1.7

Weekly downloads
13
License
MIT
Repository
github
Last release
5 years ago

:cookie: nine3-cookie-consent

A small, simple and customizable cookie consent bar for use in React applications. Based on https://github.com/Mastermindzh/react-cookie-consent

Installation

npm install nine3-cookie-consent

Using it

You can import the cookie bar like this:

import CookieConsent from "nine3-cookie-consent";

If you want to set/remove cookies yourself you can optionally import Cookies (straight from js-cookie) like this:

import CookieConsent, { Cookies } from "react-cookie-consent";

Then you can use the component anywhere in your React app like so:

<CookieConsent>
    This website uses cookies to enhance the user experience.
</CookieConsent>

You can optionally set some props like this (next chapter will show all props):

<CookieConsent buttonText="Accept" expires={150}>
    This website uses cookies to enhance the user experience.
</CookieConsent>

One of the props (onAccept) is a function, this function will be called after the user has clicked the accept button. You can provide a function like so:

<CookieConsent onAccept={() => {alert('cookie has been accepted')}}>
    ...
</CookieConsent>

Debugging it

Because the cookie consent bar will be hidden once accepted, you will have to add the prop debug to evaluate styling changes:

<CookieConsent debug>
    ...
</CookieConsent>

Note: Dont forget to remove the debug property for production.

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago