/
valslava
/
react-practice_project
Обзор
Документация
Войти
/
valslava
/
react-practice_project
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
hooks
src/component/Alert.js
20 строк
550 B
valslava2
upgrade Alert comp using hooks
27 мар 2024, 00:47
27 мар 2024, 00:47
207e3be
Код
Авторство
О чём код?
import React, {useContext} from "react" import { AlertContext } from "../context/alert/alertContext" export const Alert = () => { const {alert, hide} = useContext(AlertContext) if (!alert) return null return ( <div className={`alert alert-${alert.type || 'secondary'} alert-dismissible`} role="alert" > {alert.text} <button onClick={hide} type="button" className="close" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> ) }