I'm change the default attributes:
const blockAttrs = {
avatarSize: {
type: 'number',
default: 120, // 70 -> 120
},
//other attrs
};
Deprecated function:
deprecated: [
{
attributes: {
...blockAttrs,
avatarSize: {
type: 'number',
default: 70
}
},
save: function ( { attributes } ) {}
}
]
But when i refresh post, block still display error:
Someone
I'm change the default attributes:
const blockAttrs = {
avatarSize: {
type: 'number',
default: 120, // 70 -> 120
},
//other attrs
};
Deprecated function:
deprecated: [
{
attributes: {
...blockAttrs,
avatarSize: {
type: 'number',
default: 70
}
},
save: function ( { attributes } ) {}
}
]
But when i refresh post, block still display error:
Someone
Share Improve this question edited Oct 16, 2019 at 2:22 pdutie94 asked Oct 15, 2019 at 10:16 pdutie94pdutie94 13 bronze badges 1- Can you post the entire block code? – Welcher Commented Oct 21, 2019 at 20:35
2 Answers
Reset to default 1Looking at the documentation from https://developer.wordpress.org/block-editor/developers/block-api/block-deprecation/
I think you may need the following
migrate( { text } ) {
return {
content: text
};
},
So in your case:
migrate( { avatarSize } ) {
avatarSize: {
type: 'number',
default: 70
} content: text
};
},
Hopefully points you in the correct direction
Your save function needs to return a valid React component or null.
save: function ( { attributes } ) {}
should be
save: function ( { attributes } ) { return null; }