PHP Classes

File: src/googleauth-page/components/Notification.jsx

Recommend this page to a friend!
  Classes of Adeleye Ayodeji   WPMU Dev Plugin Test   src/googleauth-page/components/Notification.jsx   Download  
File: src/googleauth-page/components/Notification.jsx
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: WPMU Dev Plugin Test
Test WordPress plugin created using WPMU Dev
Author: By
Last change:
Date: 2 months ago
Size: 686 bytes
 

 

Contents

Class file image Download
import React, { useState, useEffect } from "react"; const Notification = ({ details }) => { const [isVisible, setIsVisible] = useState(false); useEffect(() => { //check if not empty object if (details && Object.keys(details).length) { setIsVisible(true); const timer = setTimeout(() => setIsVisible(false), 10000); return () => clearTimeout(timer); // Cleanup to prevent memory leak } }, [details]); if (!isVisible) return null; return ( <div className={`notice notice-${details.type}`} style={{ margin: 0, marginBottom: 20, }} > <div dangerouslySetInnerHTML={{ __html: details.message }} /> </div> ); }; export default Notification;