import * as React from 'react'; import { MessageBar, MessageBarType, Toggle, Text, mergeStyles } from '@fluentui/react'; import { useBoolean } from '@fluentui/react-hooks'; const wrapperClass = mergeStyles({ '> *:not(:last-child)': { marginBottom: '1.5em' }, '> * > *:not(:last-child)': { marginBottom: '0.5em' }, }); export const MessageBarNoDelayExample: React.FunctionComponent = () => { const [showAlert, { toggle: toggleShowAlert }] = useBoolean(false); const [showStatus, { toggle: toggleShowStatus }] = useBoolean(false); return (
delayedRender prop to false and setting up the
MessageBar in one of the following ways.
role="alert", the content should be read on
insertion. This role will be set automatically if messageBarType is error,{' '}
blocked, or severeWarning.
{''} which is always
rendered, and ensure the MessageBar is rendered either conditionally or with a delay. You should also set{' '}
role="none" on the MessageBar itself to prevent nested status regions.
{/* IMPORTANT: This wrapper div must always be rendered */}
{showStatus && (
This is a status message.
)}