@graphcommerce/googlerecaptcha 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1495](https://github.com/graphcommerce-org/graphcommerce/pull/1495) [`d6d3a750e`](https://github.com/graphcommerce-org/graphcommerce/commit/d6d3a750ee15c40ba022f29b923a1b872a4796ea) Thanks [@paales](https://github.com/paales)! - Solve updating state in render
8
+
9
+ - Updated dependencies [[`bed806ddd`](https://github.com/graphcommerce-org/graphcommerce/commit/bed806dddd7e025806a69798ef9587aa165d392f)]:
10
+ - @graphcommerce/graphql@3.2.0
11
+
3
12
  ## 2.1.6
4
13
 
5
14
  ### Patch Changes
@@ -1,4 +1,10 @@
1
- import { useContext } from 'react'
1
+ import { useContext, useEffect } from 'react'
2
2
  import { recaptchaContext } from '../context/recaptchaContext'
3
3
 
4
- export const useGoogleRecaptcha = () => useContext(recaptchaContext).enable?.()
4
+ export const useGoogleRecaptcha = () => {
5
+ const context = useContext(recaptchaContext)
6
+
7
+ useEffect(() => {
8
+ if (context.enabled) context.enable?.()
9
+ }, [context])
10
+ }
@@ -1,4 +1,4 @@
1
- import { GraphQLRequest, setContext } from '@graphcommerce/graphql'
1
+ import { ClientContext, GraphQLRequest, setContext } from '@graphcommerce/graphql'
2
2
 
3
3
  const isMutation = (operation: GraphQLRequest) =>
4
4
  operation.query.definitions.some(
@@ -7,7 +7,7 @@ const isMutation = (operation: GraphQLRequest) =>
7
7
  )
8
8
 
9
9
  /** Apollo link that adds the Google reCAPTCHA token to the request context. */
10
- export const recaptchaLink = setContext(async (operation, context) => {
10
+ export const recaptchaLink = setContext(async (operation, context: ClientContext) => {
11
11
  const recaptchaKey = process.env.NEXT_PUBLIC_GOOGLE_RECAPTCHA_V3_SITE_KEY
12
12
  if (!recaptchaKey || !globalThis.grecaptcha || !isMutation(operation)) return context
13
13
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/googlerecaptcha",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "2.1.6",
5
+ "version": "2.1.7",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,7 +19,7 @@
19
19
  "@types/grecaptcha": "^3.0.4"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/graphql": "3.1.3"
22
+ "@graphcommerce/graphql": "3.2.0"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "next": "12.1.2",