PactDOCS

REFERENCE / REACT

React API

Context and components layered directly over pactClient.
01

Exports

ExportKindUse
PactProviderComponentConnect context and optionally install bootstrap
PactBootstrapComponentRender exact inline bootstrap
PactGateComponentRender children only when a purpose is true
PactPreferencesButtonComponentOpen managed or headless preferences
usePact()HookRead state and actions
usePactPurpose(purpose)HookRead one boolean decision
PACT_BOOTSTRAPConstantServer-document integration
02

Context value

types.ts
typescript
interface PactContextValue {
  isReady: boolean
  isOpen: boolean
  decided: boolean
  gpc: boolean
  region: string
  purposes: PurposeDecisions
  error: Error | null
  accept(purposes?: Purpose[]): Promise<void>
  reject(purposes?: Purpose[]): Promise<void>
  save(purposes: PurposeDecisions): Promise<void>
  openPreferences(): void
  closePreferences(): void
}
OPERATETest your integration