20 行
460 B
JavaScript
20 行
460 B
JavaScript
import React, { useEffect, useState } from 'react';
|
|
|
|
export default function Alert(props){
|
|
|
|
//props.type == 'success' alert-success
|
|
//props.type == 'danger' alert-danger
|
|
|
|
|
|
useEffect(
|
|
() => {
|
|
let timer1 = setTimeout(() => props.hide(), 5000);
|
|
return () => { clearTimeout(timer1); };
|
|
},[]);
|
|
|
|
return (
|
|
<div className={`alert-${props.type} ft-16 ft-md-14`}>{props.children}</div>
|
|
)
|
|
}
|
|
|