Function AlertComponent

AlertComponent is a React functional component that displays an alert message with customizable options.

This component displays an alert with a specified message, type (success or danger), and duration. It automatically hides after the specified duration, or when clicked. The alert can also trigger an optional onHide callback when it is hidden.

import React from 'react';
import { AlertComponent } from 'mediasfu-reactjs';

function App() {
const [isAlertVisible, setIsAlertVisible] = useState(true);

const hideAlert = () => {
console.log('Alert hidden');
setIsAlertVisible(false);
};

return (
<AlertComponent
visible={isAlertVisible}
message="This is a success alert!"
type="success"
duration={3000}
onHide={hideAlert}
textColor="white"
/>
);
}

export default App;

Properties

propTypes?: any

Ignored by React.

Only kept in types for backwards compatibility. Will be removed in a future major release.

displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'