Open
Description
Explain how to use withSelect
import { withSelect } from '@wordpress/data';
const ImageInfiniteEditorWithSelect = (props) => {
const {
attributes: {
blockClass,
media,
},
} = props;
return (
<div className={blockClass}>
{
media.map((item) => {
return (<ImageEditor
blockClass={blockClass}
url={item}
/>)
})
}
</div>
);
};
export const ImageInfiniteEditor = withSelect( (select, props) => {
const {
attributes: {
media,
},
} = props;
const images = media.map((item) => {
const image = wp.data.select('core').getMedia(item);
if (typeof image !== 'undefined') {
return image.source_url;
}
});
return {
attributes: {
media: images,
},
}
})(ImageInfiniteEditorWithSelect);
Metadata
Metadata
Assignees
Labels
No labels