UNPKG

@wordpress/components

Version:
55 lines (48 loc) 1.15 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import { View } from 'react-native'; /** * WordPress dependencies */ import { useSelect, useDispatch } from '@wordpress/data'; import { store as noticesStore } from '@wordpress/notices'; /** * Internal dependencies */ import Notice from './'; import styles from './style.scss'; import { useCallback } from '@wordpress/element'; function NoticeList() { const { notices } = useSelect(select => { const { getNotices } = select(noticesStore); return { notices: getNotices() }; }, []); const { removeNotice } = useDispatch(noticesStore); const onRemoveNotice = useCallback(id => { removeNotice(id); }, [removeNotice]); if (!notices.length) { return null; } return createElement(View, { style: styles.list }, notices.map(notice => { return createElement(Notice, _extends({}, notice, { key: notice.id, onNoticeHidden: onRemoveNotice })); })); } export default NoticeList; //# sourceMappingURL=list.native.js.map