Skip to content

Commit

Permalink
FP-990: Add some examples for SectionMessage usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Sep 27, 2021
1 parent 962115f commit b3e4bec
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions client/src/components/_common/SectionMessage/SectionMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ import Message from '_common/Message';

/**
* Show an event-based message to the user
* @todo Document examples
* @example
* // Blah blah…
* <Sample jsx>
* // Basic usage
* <SectionMessage type="warning">Uh oh.</Section>
* @example
* // Manage onDismiss via props
* // CAVEAT: Available through `<Message>` but (maybe) not `<SectionMessage>`
* ...
* const [isVisible, setIsVisible] = useState(...);
*
* const onDismiss = useCallback(() => {
* setIsVisible(!isVisible);
* }, [isVisible]);
*
* return (
* <Message
* type="warning"
* isVisible={isVisible}
* onDismiss={onDismiss}
* >
* Uh oh.
* </Message>
* );
* ...
*/
const SectionMessage = props => {
const [isVisible, setIsVisible] = useState(true);
Expand Down

0 comments on commit b3e4bec

Please sign in to comment.