It turned out that allItems
gets populated …eventually. So the code in the beginning of the block must be extended to respond when allItems
is populated:
export default function Edit(props) {
const { attributes, setAttributes } = props;
const allItems = useSelect(select => select('REST-extra_table').readItems(LECTURERS_TABLE));
const [populated, setPopulated] = useState(false);
if (! populated && allItems.length !== 0) {
// further code here
setPopulated(true);
}
What I did is checking each time the block is rendered if allItems
is populated, but saving this information in State, so code which I want to run after it is populated runs only once.
Related Posts:
- Deactivate Gutenberg tips forever – not Gutenberg
- How do I register multiple blocks with block.json and register_block_type_from_metadata?
- Disable Gutenberg text-Settings in all blocks
- gutenberg block – how to force update after attribute changed?
- How can I add a custom attribute to Gutenberg core blocks?
- Add additional classes to gutenberg .editor-styles-wrapper
- How to use the WordPress < LinkControl /> Component
- Remove border radius setting from the Gutenberg button block?
- Add PHP block template to content using wp_insert_post
- Gutenberg reusable blocks – is it possible to customise an instance?
- Dynamic gutenberg block with react instead of php
- File structure and react setup when creating multiple Gutenberg blocks
- Gutenberg block get categories in SelectControl
- How to access “default” property of attribute in Gutenberg
- Gutenberg Block manipulation: Undo parse_blocks() with serialize_blocks() results in unicode issues
- How to use “getEntityRecords” for user data?
- Gutenberg: Restrict Top Level Blocks, But Not Child Blocks
- WordPress Block Variation for Gallery Columns
- How to disable alignments for block patterns?
- How to change the admin/password when using the E2E Test Utils for Gutenberg
- Create a custom render Appender button to add Inner Blocks
- Get a WordPress Gutenberg Block Attribute to use it in frontend
- Rename reusable blocks shown in navigator
- How to troubleshoot a custom Gutenberg block error: “This block has encountered an error and cannot be previewed”
- Two Gutenberg components sharing the same Panel Body in Inspector Controls
- Unable to disable Gutenberg with plugin Classic Editor or Disable Gutenberg
- How to use the @wordpress/date block in the Gutenberg editor?
- Gutenberg Block Development: Trying to add custom js script to npm start command by modifying webpack.config
- Popover in a LinkControl style
- Is there any way to render the WordPress Gutenberg core/embed block in PHP by passing in the URL?
- How to use in Block Editor – react-bootstrap?
- Double container elements on custom block in editor
- How to target block variations with has_block()?
- How to add extra option to WP core gallery block?
- Can I jump over a InnerBlocks component to target content inside with react-flickity-component?
- Use a React Component in conjunction with Blocks
- Make a custom block like default paragraph block, so that Enter starts a new block
- Custom gutenberg block not rendering with styles on frontend
- Gutenberg Block on Second Edit fails validation
- Import setAttributes() method in a separated module
- Add a hyperlink to a group block?
- Gutenberg: How to use RangeControl in the editor itself and make it work?
- How to change Block Controls Icon in Gutenberg?
- Adding content to Page settings rather than Block settings
- Detect if a block has been deleted
- Add multiple images to a custom block
- How do I disable the block marketplace for Editors?
- How to use __experimentalCaptureChildToolbar
- Why is wordpress suddenly stripping away all newline characters and how to disable this?
- Gutenberg RadioControl saving data but not not selecting radio
- Override RenderCallback from LatestPosts
- Gutenberg on block move
- Gutenberg template lock but add/delete blocks programmatically
- Notion-like editing and layout with a convenient freeform collaborative editor in WordPress? [closed]
- wp_get_global_settings is not updated on save_post hook
- How can I make Gutenberg block layout switchable without lost of current content?
- code block does not show in excerpt
- Is it possibe to prepend “ with icons or text?
- If you have multiple dynamic blocks with a post loop on a page, how do you avoid duplicates from inside the render_callback function?
- How to create Gutenberg’s pattern category automatically with custom post taxonomy terms?
- How to Change the Gutenberg editor’s colors?
- Debugging Gutenberg block with the React Profiler (React Developer Tools)
- Modify core/image block by adding inner span to figcaption in save
- How to override a function in the wp_includes folder(block supports/colors.php)
- If is block name
- Table block – Wrap table
- ResizableBox component is not selectable in block editor
- Whitelist a single SVG for use in post_content
- Gutenberg block previews suddenly not working
- WordPress Gutenberg Signal on Block Alignment Change
- When to use block patterns over nested blocks?
- How to convert block to a list block in WordPress gutenberg editor?
- How to do store, retrieve and write attributes in the registerFormatType method in Guttenberg?
- How can I create more advanced layouts in Gutenberg block editor?
- How to replace the Gutenberg default block with a custom block?
- how to disable a button added by a plugin in gutenberg toolbar?
- Images are not shown in the post editor
- Updating failed message when a wp_insert_post function is hooked to save_post hook
- Get post ancestors in the Block Editor
- How to disable blocks in Gutenberg editor for specific post type
- Possible to make the link autocompleter prioritize Tags before Posts?
- Prevent FormTokenField component to accept random entries
- How to move the customizations done in the Editor to my child theme?
- Unable to see the attributes for the custom block created
- How to register multiple blocks
- How to edit post meta by post ID in Gutenberg
- How do I change bullet on categories block?
- Add a class to img of core/cover block
- Hide title block on edit screen in Gutenberg
- How can I disable fontSizes of the Paragraph block inside the Quote block with theme.json?
- Categories, tags and thumbnails panels are not visible in the Block editor’s post menu
- How to disable the Code Editor in Gutenberg?
- Enable Gutenberg Editor when editing tags
- How to position more than one item over an image in a Gutenberg WordPress block theme
- Some CSS classes missing when rendering the page with get_the_content()
- Error with RichText Component
- Rem font size is different in the frontend and block editor
- Add to Media Inserter Categories
- Get attributes from last block created
- How do I make the block editor use https by default?