File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 11/**
22 * External dependencies.
33 */
4+ import { useEffect } from '@wordpress/element' ;
5+ import { useParams } from 'react-router-dom' ;
46import { useSelect , useDispatch } from '@wordpress/data' ;
57import { __ } from '@wordpress/i18n' ;
68
@@ -21,6 +23,9 @@ type Props = {
2123
2224export default function JobForm ( { job } : Props ) {
2325 const dispatch = useDispatch ( ) ;
26+ const { id } = useParams ( ) ;
27+ const { invalidateResolutionForStoreSelector } = useDispatch ( jobStore ) ;
28+
2429 const jobTypes : Array < Select2SingleRow > = useSelect (
2530 ( select ) => select ( jobStore ) . getJobTypes ( ) ,
2631 [ ]
@@ -36,6 +41,12 @@ export default function JobForm({ job }: Props) {
3641 [ ]
3742 ) ;
3843
44+ useEffect ( ( ) => {
45+ if ( parseInt ( id + '' ) !== form . id ) {
46+ invalidateResolutionForStoreSelector ( 'getJobDetail' ) ;
47+ }
48+ } , [ id , invalidateResolutionForStoreSelector ] ) ;
49+
3950 const loadingJobs : boolean = useSelect (
4051 ( select ) => select ( jobStore ) . getLoadingJobs ( ) ,
4152 [ ]
You can’t perform that action at this time.
0 commit comments