ZS
Size: a a a
ZS
ОЖ
ОЖ
ZS
{ isCreatable && <Компонент /> }
{ !isCreatable && <Компонент2 /> }
ОЖ
{ isCreatable && <Компонент /> }
{ !isCreatable && <Компонент2 /> }
AG
MK
AG
MK
M
MK
M
MK
B
JK
JK
JK
import React from "react";
import style from './index.scss'
const Alert = () => {
return(
<div className={style.alert}>
<Icon name="attention" fill="gray"/>
<div>Hello Word</div>
</div>
)
}
export default Alert;
const Icon = ({ name, ...rest }) => {
const ImportedIconRef = React.useRef(null);
const [loading, setLoading] = React.useState(false);
React.useEffect(() => {
setLoading(true);
const importIcon = async () => {
try {
ImportedIconRef.current = (await import(`../../assets/svg/${name}.svg`)).ReactComponent;
} catch (err) {
// Your own error handling logic, throwing error for the sake of
// simplicity
throw err;
} finally {
setLoading(false);
}
};
importIcon();
}, [name]);
if (!loading && ImportedIconRef.current) {
const { current: ImportedIcon } = ImportedIconRef;
return <ImportedIcon {...rest} />;
}
return null;
};
JK
JK
OF