Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const gutenbergSetup = () => {
const wpData = require( '@wordpress/data' );
// wp-data
const userId = 1;
const storageKey = 'WP_DATA_USER_' + userId;
wpData.use( wpData.plugins.persistence, { storageKey } );
};
const gutenbergSetup = () => {
const wpData = require( '@wordpress/data' );
// wp-data
const userId = 1;
const storageKey = 'WP_DATA_USER_' + userId;
wpData.use( wpData.plugins.persistence, { storageKey } );
};
import * as data from '@wordpress/data';
data.select('core/block-editor').isTyping();
data.dispatch('core/block-editor').resetBlocks('');
data.use(data.plugins.persistence, { storage: window.localStorage });
interface FooBar {
foo: string;
bar: number;
}
data.registerStore('foo', {
reducer(state = { foo: 'foo', bar: 21 }, action) {
return state;
},
selectors: {
getFoo: ({ foo }) => foo,
getBar: ({ bar }) => bar,
getSomething: (state, thing: keyof FooBar) => state[thing],
},
actions: {
import * as data from '@wordpress/data';
const uid = window.userSettings ? window.userSettings.uid || 1 : 1;
const storageKey = `WP_DATA_USER_${uid}`;
data.use(data.plugins.persistence, { storageKey });
data.use(data.plugins.controls);
import * as data from '@wordpress/data';
const uid = window.userSettings ? window.userSettings.uid || 1 : 1;
const storageKey = `WP_DATA_USER_${uid}`;
data.use(data.plugins.persistence, { storageKey });
data.use(data.plugins.controls);