Activity
requested review from @doritosxxx
assigned to @avbogomolov_1
6 6 error: Error; 7 onClose?: VoidFunction; 7 onClose: VoidFunction; 8 8 } 9 9 10 10 export const ErrorBox: React.FC<ErrorBoxProps> = (props) => { 11 12 const [visible, setVisible] = React.useState(true); 13 14 setTimeout(function () { 15 setVisible(false); 16 }, 5000); 17 18 setTimeout(function () { 19 props.onClose(); 20 }, 6000); - Comment on lines +14 to +20
Нельзя делать сайд-эффекты прямо в рендер-функции. Все
setTimeout
должны быть вuseEffect
с соответствующей очисткой changed this line in version 2 of the diff
9 9 10 10 export const ErrorBox: React.FC<ErrorBoxProps> = (props) => { 11 12 const [visible, setVisible] = React.useState(true); 13 14 setTimeout(function () { 15 setVisible(false); 16 }, 5000); 17 18 setTimeout(function () { 19 props.onClose(); 20 }, 6000); 21 11 22 return ( 12 <div className="error-box__container"> 23 <div className="error-box__container" style={{opacity: visible ? 1 : 0, transition: '1s opacity'}}> changed this line in version 2 of the diff
2 2 position: relative; 3 3 width: 50.0rem; 4 4 margin: 0.4rem 0.8rem; 5 border: 0.1rem solid black; 5 border: none; changed this line in version 2 of the diff
7 onClose?: VoidFunction; 7 onClose: VoidFunction; 8 8 } 9 9 10 10 export const ErrorBox: React.FC<ErrorBoxProps> = (props) => { 11 12 const [visible, setVisible] = React.useState(true); 13 14 useEffect(() => { 15 setTimeout(function () { 16 setVisible(false); 17 }, 5000); 18 19 setTimeout(function () { 20 props.onClose(); 21 }, 6000); mentioned in commit c50995c0