@@ -16,7 +16,7 @@ import { useGetRestaurantList } from "../hooks";
16
16
import RestaurantPreview from "../components/RestaurantPreview" ;
17
17
import { useTranslation } from "react-i18next" ;
18
18
import { validators , useFormo , success } from "@buildo/formo" ;
19
- import { useEffect } from "react" ;
19
+ import { useState } from "react" ;
20
20
import { PreviewPropComponent } from "../models" ;
21
21
22
22
function Home ( ) {
@@ -27,7 +27,9 @@ function Home() {
27
27
radius : 10 ,
28
28
} ;
29
29
30
- const { fieldProps, handleSubmit, values } = useFormo (
30
+ const [ activeFilters , setActiveFilters ] = useState ( initialValues ) ;
31
+
32
+ const { fieldProps, handleSubmit } = useFormo (
31
33
{
32
34
initialValues,
33
35
fieldValidators : ( ) => ( {
@@ -36,17 +38,13 @@ function Home() {
36
38
} ,
37
39
{
38
40
onSubmit : async ( values ) => {
39
- refetch ( ) ;
41
+ setActiveFilters ( values ) ;
40
42
return success ( values ) ;
41
43
} ,
42
44
}
43
45
) ;
44
46
45
- useEffect ( ( ) => {
46
- refetch ( ) ;
47
- } , [ ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
48
-
49
- const { isLoading, isError, data, refetch } = useGetRestaurantList ( values ) ;
47
+ const { isLoading, isError, data } = useGetRestaurantList ( activeFilters ) ;
50
48
51
49
if ( isLoading ) {
52
50
return < AreaLoader message = "Loading..." > </ AreaLoader > ;
0 commit comments