Skip to content

Commit 2b1d929

Browse files
committed
feat(gatsby): make store persistent via use-persistend-state
1 parent 2d96d08 commit 2b1d929

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

gatsby/src/components/consent-manager/wrapper.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22

33
import { ConsentManager, ConsentManagerForm } from "@techboi/consent-manager"
4+
import createPersistedState from "use-persisted-state"
45

56
import { matomoIntegration } from "@techboi/consent-manager-integration-matomo"
67
import { youTubeIntegration } from "@techboi/consent-manager-integration-youtube"
@@ -10,6 +11,10 @@ import "@techboi/consent-manager-interface-unobtrusive-control-ui/dist/unobtrusi
1011

1112
import { FallbackComponent } from "./fallback-component"
1213

14+
const useConsentStateStore = createPersistedState(
15+
"consent-manager-gatsby-example"
16+
)
17+
1318
const consentManagerConfig = {
1419
integrations: [
1520
matomoIntegration({
@@ -42,9 +47,7 @@ const consentManagerConfig = {
4247
}
4348

4449
export function ConsentManagerWrapper({ children }) {
45-
const storage = React.useState({
46-
decisions: {},
47-
})
50+
const storage = useConsentStateStore()
4851

4952
return (
5053
<ConsentManager

0 commit comments

Comments
 (0)