Detalhes do pacote

@reach/alert

reach379.5kMIT0.18.0

Screen-reader-friendly alert messages.

readme (leia-me)

@reach/alert

Stable release MIT license

Docs | Source | WAI-ARIA

Screen-reader-friendly alert messages. In many apps developers add "alert" messages when network events or other things happen. Users with assistive technologies may not know about the message unless you develop for it.

The Alert component will announce to assistive technologies whatever you render to the screen. If you don't have a screen reader on you won't notice a difference between rendering <Alert> vs. a <div>.

function Example(props) {
    const [messages, setMessages] = React.useState([]);
    return (
        <div>
            <button
                onClick={() => {
                    setMessages((prevMessages) =>
                        prevMessages.concat([`Message #${prevMessages.length + 1}`])
                    );
                    setTimeout(() => {
                        setMessages((prevMessages) => prevMessages.slice(1));
                    }, 5000);
                }}
            >
                Add a message
            </button>
            <div>
                {messages.map((message, index) => (
                    <Alert key={index}>{message}</Alert>
                ))}
            </div>
        </div>
    );
}

changelog (log de mudanças)

@reach/alert

0.18.0

BREAKING Changes

  • All default exports have been removed. Replace all default imports with the appropriate documented named export.
  • The output directory structure has changed slightly. Module files are now named reach-<pkg>.mjs instead of reach-<pkg>.esm.js.

Minor Changes

  • We have simplified our build setup to remove a boatload of dependencies. Build output for all packages may look slightly different, though functionally packages that don't have explicit changes marked in the release notes have not changed.

    This may affect you if you use patch-package to modify output code. If you need support for legacy browsers, the new bundle may not transpile the same ECMA features as before. In that case you may want to transpile Reach packages directly.

Patch Changes

  • Hide visual messages from screen reader to prevent double read
  • Updated dependencies:
    • @reach/utils@0.18.0
    • @reach/visually-hidden@0.18.0
    • @reach/polymorphic@0.18.0