Skip to content

Commit

Permalink
fix: callbacks are called once on accepting or on saving preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmgahete committed Mar 29, 2021
1 parent 6e5d28d commit c8ade4b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/components/CookieBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,12 @@ class CookieBanner extends React.Component {
}

onAcceptAll() {
const {
onAcceptPreferences = () => {},
onAcceptStatistics = () => {},
onAcceptMarketing = () => {},
} = this.props;

this.cookies.set(CONSENT_GIVEN);
this.cookies.set(PREFERENCES_COOKIE);
this.cookies.set(STATISTICS_COOKIE);
this.cookies.set(MARKETING_COOKIE);

onAcceptPreferences();
onAcceptStatistics();
onAcceptMarketing();
this.consetsCallback();

this.forceUpdate();
}
Expand Down Expand Up @@ -122,6 +114,8 @@ class CookieBanner extends React.Component {
this.cookies.remove(MARKETING_COOKIE);
}

this.consetsCallback();

this.forceUpdate();
}

Expand Down Expand Up @@ -205,7 +199,6 @@ class CookieBanner extends React.Component {
} = this.props;

if (this.cookies.get(CONSENT_GIVEN)) {
this.consetsCallback();
return null;
}

Expand Down

0 comments on commit c8ade4b

Please sign in to comment.