useEffect function running after page refresh, how to avoid this? #51624
Unanswered
realthemes
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @realthemes If the attributes are selectable by the user, how about using the export default function Edit( { setAttributes, clientId } ) {
const { replaceInnerBlocks } = useDispatch( blockEditorStore );
const createNewInnerBlocks = ( value ) => {
let newInnerBlocks;
// ...
replaceInnerBlocks( clientId, newInnerBlocks );
};
return (
<SelectControl
// ...
onChange={ ( value ) => {
setAttributes( { sidebarPosition: value } );
createNewInnerBlocks( value );
} }
/>
);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My useEffect function should running only if sidebarPosition attribute is changing (trigger to changing is transform variations), but when I refresh page after saving Editor blocks with content, function useEffect running again and recreate my blocks with overwriting empty content, is there the elegant method to avoid this?
Beta Was this translation helpful? Give feedback.
All reactions