Skip to content

Commit

Permalink
Added recaptcha check, cause of page reload issue (appleboy/react-rec…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcells committed Dec 5, 2019
1 parent f166e53 commit e930ac2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"react-bootstrap": "^1.0.0-beta.16",
"react-dom": "^16.12.0",
"react-helmet": "^5.2.1",
"react-recaptcha": "^2.3.10"
"react-recaptcha": "^2.3.10",
"use-ssr": "^1.0.22"
},
"devDependencies": {
"prettier": "^1.19.1"
Expand Down
6 changes: 5 additions & 1 deletion src/components/invisibleRecaptcha.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import React, { useEffect } from 'react'
import Recaptcha from 'react-recaptcha'
import useSSR from 'use-ssr'

const InvisibleRecaptcha = (props) => {
let recaptchaInstance

const { isBrowser } = useSSR();
const verifyCallback = token => { props.onVerified(token) }

useEffect(() => {
recaptchaInstance.reset()
recaptchaInstance.execute()
}, [])

if (!isBrowser)
return <React.Fragment />

return (
<React.Fragment>

<small>
This site is protected by reCAPTCHA and the Google <a href="https://policies.google.com/privacy">Privacy Policy</a> and <a href="https://policies.google.com/terms">Terms of Service</a> apply.
</small>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12603,6 +12603,11 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"

use-ssr@^1.0.22:
version "1.0.22"
resolved "https://registry.yarnpkg.com/use-ssr/-/use-ssr-1.0.22.tgz#a43c2587b1907fabda61c6542b80542c619228fe"
integrity sha512-0kA0qfI4uw7PeRsz7X0XOdl2CdbgMBSFhj3n5JzMu8ZNlcZ2NrarhGjdmoxW1Q5d3WtNKbCNIjns/CKhpL7z8g==

use@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
Expand Down

0 comments on commit e930ac2

Please sign in to comment.