const onDrop = useCallback(async (acceptedFiles) => {
const newImage = acceptedFiles[0];
let hasError;
if (newImage.size > allowedMaximumFileSize) {
hasError = true;
alert("Размер файла не допустим");
}
if (!allowedMimeTypes.includes(newImage.type)) {
hasError = true;
alert("Тип файла не допустим");
}
if (!hasError) {
const previewBASE64 = await fileReader(newImage);
onImageChange(name, { file: newImage, preview: previewBASE64 });
}
}, []);
{
test: /\.html$/,
use: [{ loader: 'html-loader', options: { interpolate: true } }],
},
<body>
...
${require('./../includes/header.html')}
...
</body>
const withTheme = Component => ({ userPalette, ...props }) => (
<ThemeProvider theme={defaultMaterialTheme(userPalette)}>
<Component {...props} />
</ThemeProvider>
);
export default compose(
hot,
connect(mapStateToProps),
withTheme,
)(Routes);
start 3
start 2
start 1
start 0
end
start 0
end
start 1
start 0
end
end
start 2
start 1
start 0
end
start 0
end
useEffect(() => {
const abortController = new AbortController();
const fetchData = async () => {
await fetch(url, { abortController }).then((data: any) => {
setImg(data);
setPreloader(!preloader);
});
};
fetchData();
return () => {
abortController.abort();
}
}, [url]);
useEffect(() => {
let isMounted = true;
const fetchData = async () => {
...
if (isMounted) {
setImg(data);
setPreloader(!preloader);
}
...
}
...
return () => { isMounted = false; };
}, [])
deleteItem: React.MouseEventHandler<T>
walk(obj, () => {}, (obj) => {
const nodeValue = obj.children[0].value;
if (nodeValue.value == 'placeholder' || nodeValue.value == 'button') {
arr.push({
[nodeValue.value]: {
index: nodeValue.loc.start.line,
loc: obj.loc
}
});
}
['placeholder', 'button', ...].includes(node.value);