Skip to content

Commit

Permalink
debugged two issues, see details
Browse files Browse the repository at this point in the history
added a missing return statement inside a map method and disabled eslinter for one line of code in useeffect.
  • Loading branch information
stefanibus committed Jun 24, 2021
1 parent fbd7d35 commit 4f4b424
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const Api = {
const resProperties = responses[2];

const modifyData = (typeInfo, array) => {

array.data.map((iteration, index) => {
array.data.map((iteration, index) => {
iteration['type'] = typeInfo
iteration['id'] = iteration.id+'-'+typeInfo
return iteration
})
}
modifyData('agent', resAgents);
Expand Down
13 changes: 7 additions & 6 deletions src/components/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function List() {
const [checkedAgents, setCheckedAgents] = useState(true);
const [checkedShops, setCheckedShops] = useState(true);
const [checkedProperties, setCheckedProperties] = useState(true);
const [fullData, setFullData] = useState(spinnerLoadingData); //
const [resultList, setResultList] = useState( spinnerLoadingData ); //
const [filteredList, setFilteredList] = useState( spinnerLoadingData ); //
const [fullData, setFullData] = useState(spinnerLoadingData);
const [resultList, setResultList] = useState(spinnerLoadingData);
const [filteredList, setFilteredList] = useState(spinnerLoadingData);
const [inputValue, setInputValue] = useState('')
const [listOfNames, setListOfNames] = useState([]);
const [sorting, setSorting] = useState(false);
Expand Down Expand Up @@ -51,11 +51,9 @@ function List() {


useEffect( () => {
// all Three Checkboxes are checked
if ((checkedAgents) && (checkedShops) && (checkedProperties)) {
setFilteredList(fullData)
}
// none of the three checkboxes are selected
else if ((!checkedAgents) && (!checkedShops) && (!checkedProperties)) {
setFilteredList({'mergedArray' : [] })
}
Expand All @@ -71,7 +69,10 @@ function List() {
});
setFilteredList({'mergedArray' : result})
}
}, [checkedAgents, checkedShops , checkedProperties, fullData.whenToUpdateProp]);
},
// alternatively to disabling the esLinter for the below line to not print a warning-message in the console, I would have to establish useReducer instead of fullData
// eslint-disable-next-line react-hooks/exhaustive-deps
[checkedAgents, checkedShops , checkedProperties, fullData.whenToUpdateProp]);



Expand Down

0 comments on commit 4f4b424

Please sign in to comment.