Skip to content

Commit

Permalink
fix: 🐛 tag/size 搜索条件相关问题
Browse files Browse the repository at this point in the history
  • Loading branch information
meetqy committed Mar 6, 2023
1 parent 7de46bf commit 2e601e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
32 changes: 13 additions & 19 deletions components/JustifyLayout/SearchModule/Size.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { CaretDownOutlined } from "@ant-design/icons";
import { Col, InputNumber, Popover, Row, Typography } from "antd";
import _ from "lodash";
import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";

interface Props {
value: EagleUse.SearchParams["size"];
onChange: (value: EagleUse.SearchParams["size"]) => void;
}

const Size = (props: Props) => {
const [value, setValue] = useState<EagleUse.SearchParams["size"]>({
width: {
min: 0,
max: 0,
},
height: {
min: 0,
max: 0,
},
});

useEffect(() => {
if (_.isEqual(props.value, value)) return;
if (!props.value) return;

setValue(props.value);
}, [props.value, value]);
const [value, setValue] = useState<EagleUse.SearchParams["size"]>(
props.value || {
width: {
min: 0,
max: 0,
},
height: {
min: 0,
max: 0,
},
}
);

const changeValue = (
e: number,
Expand Down
10 changes: 2 additions & 8 deletions components/JustifyLayout/SearchModule/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { tagsState } from "@/store";
import { Select } from "antd";
import _ from "lodash";
import { useEffect, useState } from "react";
import { useState } from "react";
import { useRecoilValue } from "recoil";
interface Props {
value: string[];
Expand All @@ -10,12 +9,7 @@ interface Props {

const Tag = (props: Props) => {
const tags = useRecoilValue(tagsState);
const [value, setValue] = useState<string[]>([]);

useEffect(() => {
if (_.isEqual(props.value, value)) return;
setValue(props.value);
}, [props.value, value]);
const [value, setValue] = useState<string[]>(props.value || []);

const onChange = (value: string[]) => {
setValue(value);
Expand Down

0 comments on commit 2e601e5

Please sign in to comment.