Skip to content

Commit

Permalink
Merge 0ea681b into 0fd9791
Browse files Browse the repository at this point in the history
  • Loading branch information
nandereck committed Jul 11, 2023
2 parents 0fd9791 + 0ea681b commit f7aba5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-pianos-draw.md
@@ -0,0 +1,5 @@
---
'@hashicorp/react-consent-manager': minor
---

Add onload functionality to scripts handled by ConsentManager
1 change: 1 addition & 0 deletions packages/consent-manager/scripts/custom.tsx
Expand Up @@ -31,6 +31,7 @@ function CustomScript({ service }: CustomScriptProps) {
strategy={strategy}
id={service.name}
{...dataAttrs}
onLoad={service?.onLoad}
>
{service.body ? service.body : null}
</Script>
Expand Down
6 changes: 6 additions & 0 deletions packages/consent-manager/types.ts
Expand Up @@ -19,6 +19,12 @@ export interface ConsentManagerService {
* If left undefined, script will load as usual.
*/
shouldLoad?: () => boolean
/**
* Optional function that runs when a script has
* finished loading.
* Docs: https://nextjs.org/docs/pages/api-reference/components/script#onload
*/
onLoad?: () => void
}

export interface ConsentManagerPreset {
Expand Down

0 comments on commit f7aba5f

Please sign in to comment.