mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-01-20 18:41:44 +01:00
Set cookie value before handling side-effects (#76)
This commit is contained in:
parent
8561858333
commit
4fa6476406
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### changed
|
||||
|
||||
- Set cookie value before handling side-effects.
|
||||
|
||||
## [5.1.0]
|
||||
|
||||
A new feature! This time it's an "overlay" on the entire website to block access whilst the cookiebar is displayed.
|
||||
|
12
src/index.js
12
src/index.js
@ -118,14 +118,14 @@ class CookieConsent extends Component {
|
||||
accept({ acceptedByScrolling = false }) {
|
||||
const { cookieName, cookieValue, hideOnAccept, onAccept } = this.props;
|
||||
|
||||
this.setCookie(cookieName, cookieValue);
|
||||
|
||||
// fire onAccept
|
||||
onAccept({ acceptedByScrolling });
|
||||
|
||||
// remove listener if set
|
||||
window.removeEventListener("scroll", this.handleScroll);
|
||||
|
||||
this.setCookie(cookieName, cookieValue);
|
||||
|
||||
if (hideOnAccept) {
|
||||
this.setState({ visible: false });
|
||||
}
|
||||
@ -145,16 +145,16 @@ class CookieConsent extends Component {
|
||||
setDeclineCookie,
|
||||
} = this.props;
|
||||
|
||||
if (setDeclineCookie) {
|
||||
this.setCookie(cookieName, declineCookieValue);
|
||||
}
|
||||
|
||||
// fire onDecline
|
||||
onDecline();
|
||||
|
||||
// remove listener if set
|
||||
window.removeEventListener("scroll", this.handleScroll);
|
||||
|
||||
if (setDeclineCookie) {
|
||||
this.setCookie(cookieName, declineCookieValue);
|
||||
}
|
||||
|
||||
if (hideOnDecline) {
|
||||
this.setState({ visible: false });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user