File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
import Router from "next/router" ;
2
2
import Layout from "../components/Layout" ;
3
- import { useState , useEffect , useRef } from "react" ;
3
+ import { useState , useEffect , useRef , useCallback } from "react" ;
4
4
import { createIdea } from "../apiClient" ;
5
5
import { RECENT } from "../components/IdeaOrder" ;
6
6
import { GoogleReCaptcha } from "react-google-recaptcha-v3" ;
@@ -16,7 +16,12 @@ export default () => {
16
16
const [ tagInput , setTagInput ] = useState ( "" ) ;
17
17
const [ tags , setTags ] = useState ( [ ] ) ;
18
18
const tagInputElement = useRef ( null ) ;
19
+ const [ refreshReCaptcha , setRefreshReCaptcha ] = useState ( false ) ;
19
20
21
+ const onVerify = useCallback ( ( token ) => {
22
+ setToken ( token ) ;
23
+ } , [ ] ) ;
24
+
20
25
const removeTag = ( key ) => {
21
26
const index = tags . findIndex ( ( tag ) => tag === key ) ;
22
27
console . log ( index ) ;
@@ -95,6 +100,8 @@ export default () => {
95
100
} finally {
96
101
setIsCreating ( false ) ;
97
102
}
103
+
104
+ setRefreshReCaptcha ( r => ! r ) ;
98
105
} ;
99
106
100
107
useEffect ( ( ) => {
@@ -198,9 +205,8 @@ export default () => {
198
205
</ div >
199
206
< div className = "field" >
200
207
< GoogleReCaptcha
201
- onVerify = { ( token ) => {
202
- setToken ( token ) ;
203
- } }
208
+ onVerify = { onVerify }
209
+ refreshReCaptcha = { refreshReCaptcha }
204
210
/>
205
211
</ div >
206
212
< div className = "field" >
You can’t perform that action at this time.
0 commit comments