feat: rewrite component use effect
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Button, Card, Col, Input, Row, Tabs } from "antd";
|
||||
import { FilterOutlined, PlusSquareOutlined } from "@ant-design/icons";
|
||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { LINKS } from "../../routes/app";
|
||||
import { CategoryComponent } from "../../component/CategoryComponent";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {Button, Card, Col, Input, Row, Tabs} from "antd";
|
||||
import {FilterOutlined, PlusSquareOutlined} from "@ant-design/icons";
|
||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
import {LINKS} from "../../routes/app";
|
||||
import {CategoryComponent} from "../../component/CategoryComponent";
|
||||
|
||||
const { TabPane } = Tabs;
|
||||
const { Search } = Input;
|
||||
const {TabPane} = Tabs;
|
||||
const {Search} = Input;
|
||||
|
||||
export const Category = observer(() => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -18,7 +18,6 @@ export const Category = observer(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
//await store.product.getDataCategories();
|
||||
await store.category.getData();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
@@ -29,11 +28,6 @@ export const Category = observer(() => {
|
||||
init();
|
||||
}, []);
|
||||
|
||||
const handleChangeTabPane = async (key) => {
|
||||
store.product.filterCategory = key;
|
||||
console.log(key);
|
||||
};
|
||||
|
||||
const routeData = [
|
||||
{
|
||||
route: LINKS.HOME,
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Button, Card, Col, Input, Row, Tabs } from "antd";
|
||||
import { FilterOutlined, PlusSquareOutlined } from "@ant-design/icons";
|
||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { LINKS } from "../../routes/app";
|
||||
import { SubcategoryComponent } from "../../component/Subcategory";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {Button, Card, Col, Input, Row} from "antd";
|
||||
import {PlusSquareOutlined} from "@ant-design/icons";
|
||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
import {LINKS} from "../../routes/app";
|
||||
import {SubcategoryComponent} from "../../component/Subcategory";
|
||||
|
||||
const { Search } = Input;
|
||||
const {Search} = Input;
|
||||
|
||||
export const Subcategory = observer(() => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -17,7 +17,7 @@ export const Subcategory = observer(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
// await getData();
|
||||
getData();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
@@ -31,6 +31,7 @@ export const Subcategory = observer(() => {
|
||||
await store.category.getData();
|
||||
await store.subcategory.getData();
|
||||
};
|
||||
|
||||
const routeData = [
|
||||
{
|
||||
route: LINKS.HOME,
|
||||
|
Reference in New Issue
Block a user