You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to do some actions when block is deleted from editor. I currently use this code:
// cleanup of meta data from post, note that return value is cleanup functionuseEffect(()=>()=>{setMeta({ ...meta,term_definition: terms.filter(el=>el.ID!==attributes.ID)});deleteEntityRecord('extra_table/v1','events_meta',events_meta_ID);},[]);
However, it seems that sometimes block variables (attributes and state - events_meta_ID is local state to block) are asynchronously deleted before this code is run and therefore this code fails. Is there proper way to do this - with one exception: I would not like to use class components instead of functions for block definition. So please, no componentWillUnmount() solutions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to do some actions when block is deleted from editor. I currently use this code:
However, it seems that sometimes block variables (attributes and state -
events_meta_ID
is local state to block) are asynchronously deleted before this code is run and therefore this code fails. Is there proper way to do this - with one exception: I would not like to use class components instead of functions for block definition. So please, nocomponentWillUnmount()
solutions?Beta Was this translation helpful? Give feedback.
All reactions