Last active
August 25, 2022 22:54
-
-
Save danieliser/9c2279110f5083b8b9136cc3bdaf7f1e to your computer and use it in GitHub Desktop.
broken @wordpress/core-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import domReady from '@wordpress/dom-ready'; | |
import { render } from '@wordpress/element'; | |
import { | |
createRegistry, | |
RegistryProvider, | |
useSelect | |
} from '@wordpress/data'; | |
import { store as coreStore } from '@wordpress/core-data'; | |
const App = () => { | |
const test = useSelect( ( select ) => { | |
return select( coreStore ); | |
}, [] ); | |
console.log( test ); | |
return <>{ 'test' }</>; | |
}; | |
const registry = createRegistry( {} ); | |
registry.register( coreStore ); | |
console.log( 'init registry', { ...registry } ); | |
domReady( () => { | |
render( | |
<RegistryProvider value={ registry }> | |
<App /> | |
</RegistryProvider>, | |
document.getElementById( 'content-control-root-container' ) | |
); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works now