Simplified hasDuplicates function

This commit is contained in:
vpopescu
2022-06-14 16:44:08 +02:00
parent 8df935829d
commit 052bf17292

View File

@@ -5,17 +5,7 @@ import PropTypes from "prop-types";
import GroupSelect from "../GroupSelect/GroupSelect"; import GroupSelect from "../GroupSelect/GroupSelect";
import DynamicTable from "../DynamicTable/DynamicTable"; import DynamicTable from "../DynamicTable/DynamicTable";
function hasDuplicates(array) {
var valuesSoFar = Object.create(null);
for (var i = 0; i < array.length; ++i) {
var value = array[i];
if (value in valuesSoFar) {
return true;
}
valuesSoFar[value] = true;
}
return false;
}
const GroupEdit = (props) => { const GroupEdit = (props) => {
var [selected, setSelected] = useState([]), var [selected, setSelected] = useState([]),
@@ -24,7 +14,7 @@ const GroupEdit = (props) => {
limit = useSelector((state) => state.limit); limit = useSelector((state) => state.limit);
var dispatch = useDispatch(); var dispatch = useDispatch();
const hasDuplicates = a => a.filter((e, i) => a.indexOf(e) != i).length > 0
const dispatchPageUpdate = (data, page) => { const dispatchPageUpdate = (data, page) => {
dispatch({ dispatch({
type: "GROUPS_PAGE", type: "GROUPS_PAGE",