Ecommerce Shopify WordPress Discussion

wp.data.dispatch( 'core' ) returns null

I am following the tutorial "Build your first block" and have a folder structure representing the scaffold created by the npx @wordpress/create-block@latest command. Using it as my starting point, I'm trying to retrieve the WordPress core store to add an entity, but I keep getting the error "Uncaught TypeError: Cannot read properties of null (reading 'addEntities')". Here is the whole src/index.js file with the code I have added starting at import { dispatch } from '@wordpress/data'; (scaffold comments removed for brevity). import { registerBlockType } from '@wordpress/blocks'; import './style.scss'; import Edit from './edit'; import metadata from './block.json'; registerBlockType( metadata.name, { /** * @see ./edit.js */ edit: Edit, } ); import { dispatch } from '@wordpress/data'; dispatch( 'core' ).addEntities( [ { name: 'programs', kind: 'amilia/v1', baseURL: 'amilia/v1/programs', }, ] ); It appears dispatch( 'core' ) returns null and I have no idea why. Should I be calling it in a different place?
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.