Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22c1e00

Browse filesBrowse files
authored
1 parent 3f0903e commit 22c1e00
Copy full SHA for 22c1e00

File tree

Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed

‎src/components/Table/index.js

Copy file name to clipboardExpand all lines: src/components/Table/index.js
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const iconPath = `${process.env.PUBLIC_URL}/assets/icons/`;
2929

3030
const Table = () => {
3131
const data = React.useMemo(() => questions, []);
32-
32+
const [resetCount, setResetCount] = useState(0);
3333
let checkedList =
3434
JSON.parse(localStorage.getItem('checked')) ||
3535
new Array(data.length).fill(false);
@@ -81,6 +81,15 @@ const Table = () => {
8181
[],
8282
);
8383

84+
const resetHandler = () => {
85+
setChecked(new Array(checked.length).fill(false));
86+
setDifficultyCount(() => {
87+
return { Easy: 0, Medium: 0, Hard: 0 };
88+
});
89+
const count = resetCount + 1;
90+
setResetCount(count);
91+
};
92+
8493
const columns = React.useMemo(
8594
() => [
8695
{
@@ -139,10 +148,7 @@ const Table = () => {
139148
outline
140149
size="sm"
141150
color="danger"
142-
onClick={() => {
143-
setDifficultyCount({ Easy: 0, Medium: 0, Hard: 0 });
144-
setChecked([...checked].map(() => false));
145-
}}
151+
onClick={resetHandler}
146152
>
147153
Reset
148154
</Button>
@@ -164,7 +170,6 @@ const Table = () => {
164170
difficultyCount[
165171
cellInfo.row.original.difficulty
166172
] += additive;
167-
168173
setDifficultyCount(difficultyCount);
169174
setChecked([...checked]);
170175
}}
@@ -336,7 +341,7 @@ const Table = () => {
336341
},
337342
],
338343
// eslint-disable-next-line
339-
[],
344+
[resetCount],
340345
);
341346

342347
const {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.