|
| 1 | +import { useReducer, useRef, useCallback } from 'react' |
1 | 2 | import { encodeFormData } from './utils' |
2 | 3 | import NetlifyFormReducer from './netlify-form-reducer' |
3 | 4 | import { NetlifyFormProvider } from './netlify-form-context' |
@@ -25,9 +26,9 @@ export const useNetlifyForm = ({ |
25 | 26 | recaptchaEnabled: enableRecaptcha, |
26 | 27 | recaptchaInvisible: false |
27 | 28 | } |
28 | | - const [state, dispatch] = React.useReducer(NetlifyFormReducer, initialState) |
29 | | - const formRef = React.useRef(null) |
30 | | - const recaptchaRef = React.useRef(null) |
| 29 | + const [state, dispatch] = useReducer(NetlifyFormReducer, initialState) |
| 30 | + const formRef = useRef(null) |
| 31 | + const recaptchaRef = useRef(null) |
31 | 32 |
|
32 | 33 | const handleChange = ({ target: { name, value, files } }) => { |
33 | 34 | dispatch({ |
@@ -84,10 +85,10 @@ export const useNetlifyForm = ({ |
84 | 85 | dispatch({ type: 'SET_SUCCESS' }) |
85 | 86 | return onSuccess(response, context) |
86 | 87 | } |
87 | | - const setHoneypotName = React.useCallback((ref) => { |
| 88 | + const setHoneypotName = useCallback((ref) => { |
88 | 89 | return dispatch({ type: 'SET_HONEYPOT_NAME', payload: ref }) |
89 | 90 | }, []) |
90 | | - const enableRecaptchaHandler = React.useCallback((enable) => { |
| 91 | + const enableRecaptchaHandler = useCallback((enable) => { |
91 | 92 | return dispatch({ type: 'ENABLE_RECAPTCHA', payload: enable }) |
92 | 93 | }, []) |
93 | 94 |
|
|
0 commit comments