const addedFiles = [];
const createImprint = (file) => {
const payload = [file.name, file.type, file.size, file.lastModified];
return payload.map(entry => btoa(encodeURIComponent(entry))).join('_');
};
input.addEventListener('change', event => {
const { files } = event.target;
const existingImprints = addedFiles.map(entry => entry.imprint);
for (const file of files) {
const imprint = createImprint(file);
if (!existingImprints.includes(imprint)) {
addedFiles.push({
file,
imprint
});
}
}
event.target.value = '';
});
- fetch('https://facejsonserver.000webhostapp.com/data.json')
+ fetch('https://facejsonserver.000webhostapp.com/')
React.lazy
просто обёртка. const steps = [
{
name: 'Шаг 1',
component: React.lazy(() => import('./steps/step1.jsx'))
},
{
name: 'Шаг 2',
component: React.lazy(() => import('./steps/step2.jsx'))
}
];
Если нигде не используется filter в самом начале, то можно собирать его перед отправкой формы