|
@@ -7,22 +7,23 @@ import { useDispatch, useSelector } from "react-redux";
|
|
import {
|
|
import {
|
|
fetchExploreHome,
|
|
fetchExploreHome,
|
|
fetchExploreSearch,
|
|
fetchExploreSearch,
|
|
- resetExploreHome
|
|
|
|
|
|
+ resetExploreHome,
|
|
} from "@src/store/reducers/ExploreReducer";
|
|
} from "@src/store/reducers/ExploreReducer";
|
|
import useExploreFilter from "@src/hooks/useExploreFilter";
|
|
import useExploreFilter from "@src/hooks/useExploreFilter";
|
|
import { useCallbackAwaitStateSync } from "use-callback-await-state-sync";
|
|
import { useCallbackAwaitStateSync } from "use-callback-await-state-sync";
|
|
import useMore from "@src/hooks/useMore";
|
|
import useMore from "@src/hooks/useMore";
|
|
import URLInfo from "@src/constants/URLInfo";
|
|
import URLInfo from "@src/constants/URLInfo";
|
|
import { IFilter } from "metarare";
|
|
import { IFilter } from "metarare";
|
|
|
|
+import { useIsFirstRender } from "usehooks-ts";
|
|
|
|
|
|
const cx = classNames.bind(styles);
|
|
const cx = classNames.bind(styles);
|
|
|
|
|
|
interface IOwnProps {}
|
|
interface IOwnProps {}
|
|
|
|
|
|
const Explore: React.FC<IOwnProps> = ({}) => {
|
|
const Explore: React.FC<IOwnProps> = ({}) => {
|
|
|
|
+ const isFirstRender = useIsFirstRender();
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
const { list, isExploreListLoaded } = useSelector((store) => store.explore);
|
|
const { list, isExploreListLoaded } = useSelector((store) => store.explore);
|
|
-
|
|
|
|
const searchText = new URLSearchParams(location.search).get(
|
|
const searchText = new URLSearchParams(location.search).get(
|
|
URLInfo.SEARCH_PARAM.SEARCH_TEXT
|
|
URLInfo.SEARCH_PARAM.SEARCH_TEXT
|
|
);
|
|
);
|
|
@@ -40,14 +41,13 @@ const Explore: React.FC<IOwnProps> = ({}) => {
|
|
currency_amount_end: filterProps.maxPrice,
|
|
currency_amount_end: filterProps.maxPrice,
|
|
currency_amount_start: filterProps.minPrice,
|
|
currency_amount_start: filterProps.minPrice,
|
|
network: filterProps.networkType,
|
|
network: filterProps.networkType,
|
|
- sale_type: filterProps.saleType
|
|
|
|
|
|
+ sale_type: filterProps.saleType,
|
|
};
|
|
};
|
|
-
|
|
|
|
if (searchText) {
|
|
if (searchText) {
|
|
dispatch(
|
|
dispatch(
|
|
fetchExploreSearch({
|
|
fetchExploreSearch({
|
|
...commonBody,
|
|
...commonBody,
|
|
- token_name: searchText
|
|
|
|
|
|
+ token_name: searchText,
|
|
})
|
|
})
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
@@ -59,7 +59,7 @@ const Explore: React.FC<IOwnProps> = ({}) => {
|
|
{
|
|
{
|
|
list,
|
|
list,
|
|
dispatchFnc: dispatchExploreHome,
|
|
dispatchFnc: dispatchExploreHome,
|
|
- setSelectedFilterType: filterProps.setSelectedFilterType
|
|
|
|
|
|
+ setSelectedFilterType: filterProps.setSelectedFilterType,
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
@@ -74,8 +74,9 @@ const Explore: React.FC<IOwnProps> = ({}) => {
|
|
});
|
|
});
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
+ if (isFirstRender) return;
|
|
fetchInit();
|
|
fetchInit();
|
|
- }, [location.search]);
|
|
|
|
|
|
+ }, [searchText]);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={cx("explore")}>
|
|
<div className={cx("explore")}>
|