File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
- import { useState , useRef } from 'react'
1
+ import { useState , useRef , useEffect } from 'react'
2
2
import cx from 'classnames'
3
+ import { useRouter } from 'next/router'
3
4
import { ThumbsdownIcon , ThumbsupIcon } from '@primer/octicons-react'
4
5
import { useTranslation } from 'components/hooks/useTranslation'
5
6
import { Link } from 'components/Link'
@@ -13,10 +14,18 @@ enum ViewState {
13
14
}
14
15
15
16
export const Survey = ( ) => {
17
+ const { asPath } = useRouter ( )
16
18
const { t } = useTranslation ( 'survey' )
17
19
const [ state , setState ] = useState < ViewState > ( ViewState . START )
18
20
const formRef = useRef < HTMLFormElement > ( null )
19
21
22
+ useEffect ( ( ) => {
23
+ // Always reset the form if navigating to a new page because what
24
+ // you might have said or started to say belongs exclusively to
25
+ // to the page you started on.
26
+ setState ( ViewState . START )
27
+ } , [ asPath ] )
28
+
20
29
function vote ( state : ViewState ) {
21
30
return ( ) => {
22
31
trackEvent ( getFormData ( ) )
You can’t perform that action at this time.
0 commit comments