Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
import type { AnyConfig, StoreDescriptor, DispatchReturn } from './types';
|
|
import defaultRegistry from './default-registry';
|
|
|
|
/**
|
|
* Given a store descriptor, returns an object of the store's action creators.
|
|
* Calling an action creator will cause it to be dispatched, updating the state value accordingly.
|
|
*
|
|
* Note: Action creators returned by the dispatch will return a promise when
|
|
* they are called.
|
|
*
|
|
* @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing
|
|
* the store name is also supported.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* import { dispatch } from '@wordpress/data';
|
|
* import { store as myCustomStore } from 'my-custom-store';
|
|
*
|
|
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
|
|
* ```
|
|
* @return Object containing the action creators.
|
|
*/
|
|
export function dispatch<
|
|
StoreNameOrDescriptor extends StoreDescriptor< AnyConfig > | string,
|
|
>(
|
|
storeNameOrDescriptor: StoreNameOrDescriptor
|
|
): DispatchReturn< StoreNameOrDescriptor > {
|
|
return defaultRegistry.dispatch( storeNameOrDescriptor );
|
|
}
|