There was an error while loading. Please reload this page.
1 parent fa6d81b commit b73eed2Copy full SHA for b73eed2
src/App.js
@@ -1,5 +1,5 @@
1
import './App.css';
2
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
3
4
function App() {
5
@@ -53,14 +53,17 @@ function App() {
53
// update state
54
setPreferences(updatedPreference);
55
56
+ }
57
+
58
+ // check preferences are updated then we will check if all check box are selected then mark select all else mark false
59
+ useEffect(() => {
60
61
// we also check if all items are selected
62
let allChecked = preferences.every(preference => preference.selected === true);
63
- if (allChecked === true) {
- setAllFav(allChecked);
- }
-
64
+ setAllFav(allChecked);
65
66
+ }, [preferences])
67
68
69
return (
0 commit comments