Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 604391d

Browse files
committedJan 6, 2021
fix: issue #37 again
1 parent 5596aad commit 604391d

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed
 

‎package-lock.json

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
"redux": "^4.0.5",
7676
"redux-logger": "^3.0.6",
7777
"redux-promise-middleware": "^6.1.2",
78-
"redux-thunk": "^2.3.0",
79-
"use-debounce": "^5.2.0"
78+
"redux-thunk": "^2.3.0"
8079
},
8180
"browserslist": [
8281
"last 1 version",

‎src/routes/MyTeamsList/index.jsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,36 @@
66
import React, { useCallback, useState, useEffect } from "react";
77
import _ from "lodash";
88
import LayoutContainer from "components/LayoutContainer";
9-
import { useDebouncedCallback } from "use-debounce";
109
import PageHeader from "components/PageHeader";
1110
import Input from "components/Input";
1211
import Pagination from "components/Pagination";
1312
import { getMyTeams } from "../../services/teams";
1413
import TeamCard from "./components/TeamCard";
1514
import TeamCardGrid from "./components/TeamCardGrid";
1615
import LoadingIndicator from "../../components/LoadingIndicator";
17-
import { useAsync } from "react-use";
16+
import { useDebounce } from "react-use";
1817
import { TEAMS_PER_PAGE } from "constants";
1918
import "./styles.module.scss";
2019

2120
const MyTeamsList = () => {
22-
// let [myTeams, loadingError] = useData(getMyTeams);
23-
let [myTeams, setMyTeams] = useState();
21+
let [myTeams, setMyTeams] = useState(null);
2422
const [filter, setFilter] = useState("");
23+
const [tempFilter, setTempFilter] = React.useState('');
2524
const [loadingError, setLoadingError] = useState(false);
2625
const [page, setPage] = useState(1);
2726
const [total, setTotal] = useState(0);
27+
const onFilterChange = (evt) => {
28+
setTempFilter(evt.target.value)
29+
}
2830

29-
const onFilterChange = useDebouncedCallback((value) => {
30-
setFilter(value);
31+
useDebounce((value) => {
32+
console.log('xxxx', value)
33+
setFilter(tempFilter);
3134
setPage(1);
32-
}, 200);
35+
}, 200, [tempFilter]);
3336

3437
useEffect(() => {
38+
setMyTeams(null);
3539
getMyTeams(filter, page, TEAMS_PER_PAGE)
3640
.then((response) => {
3741
setMyTeams(response.data);
@@ -57,10 +61,11 @@ const MyTeamsList = () => {
5761
<Input
5862
placeholder="Filter by team name"
5963
styleName="filter-input"
60-
onChange={(e) => onFilterChange.callback(e.target.value)}
64+
onChange={onFilterChange}
6165
/>
6266
}
6367
/>
68+
{myTeams && myTeams.length === 0 && (<div styleName="empty">No teams found</div>)}
6469
{!myTeams ? (
6570
<LoadingIndicator error={loadingError && loadingError.toString()} />
6671
) : (

‎src/routes/MyTeamsList/styles.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
}
1919
}
2020

21+
.empty {
22+
text-align: center;
23+
}
2124

2225
.pagination-wrapper {
2326
margin-top: 20px;

0 commit comments

Comments
 (0)
This repository has been archived.