Hey guys, thanks for the awesome work around Gutenberg. I want to report the following issue that another guy reproduced already.
Issue Overview
When withAPIData is used, the data is loaded only when the block is added freshly to Gutenberg. If the block was already added and someone reloads the whole page, there is no data.
export default registerBlockType(
'whatever/categories',
{
title: 'Whatever',
category: 'widgets',
icon: 'list-view',
keywords: [],
supports: {
html: false,
},
attributes: {
headline: {
type: 'string',
default: 'Whatever',
},
},
edit: withAPIData( function () {
return {
categoriesList: '/wp/v2/categories?per_page=100&_fields=id,name,parent',
}
} )( ( props ) => {
console.log(props.categoriesList); // no data once the page reloads
return <div>whatever</div>;
} ),
save: props => {
return null;
},
},
);
Steps to Reproduce (for bugs)
- Add the block to Gutenberg.
props.categoriesList.data exists and has data.
- Reload the page (by pressing the browsers reload-button).
- REST-Request finishes with code 200, however
props.categoriesList.data is undefined.
I used Firefox developer edition 60.0b16 (64-Bit). But could reproduce it with Chrome 66.0.3359.139 as well.
Expected Behavior
In the example above, props.categoriesList should return {get: ƒ, isLoading: false, path: "/wp/v2/posts?per_page=4", create: ƒ, isCreating: false, data: [array data]}
Current Behavior
In the example above, props.categoriesList returns {get: ƒ, isLoading: true, path: "/wp/v2/posts?per_page=4", create: ƒ, isCreating: false]} (no data)
Possible Solution
That's the question.
Hey guys, thanks for the awesome work around Gutenberg. I want to report the following issue that another guy reproduced already.
Issue Overview
When withAPIData is used, the data is loaded only when the block is added freshly to Gutenberg. If the block was already added and someone reloads the whole page, there is no data.
Steps to Reproduce (for bugs)
props.categoriesList.dataexists and has data.props.categoriesList.dataisundefined.I used Firefox developer edition 60.0b16 (64-Bit). But could reproduce it with Chrome 66.0.3359.139 as well.
Expected Behavior
In the example above,
props.categoriesListshould return{get: ƒ, isLoading: false, path: "/wp/v2/posts?per_page=4", create: ƒ, isCreating: false, data: [array data]}Current Behavior
In the example above,
props.categoriesListreturns{get: ƒ, isLoading: true, path: "/wp/v2/posts?per_page=4", create: ƒ, isCreating: false]}(no data)Possible Solution
That's the question.