set initial blocks from the store
This commit is contained in:
parent
c296776121
commit
69914eea34
|
@ -43,7 +43,6 @@ type IframeEditorProps = {
|
|||
};
|
||||
|
||||
export function IframeEditor( {
|
||||
initialBlocks = [],
|
||||
onChange = () => {},
|
||||
onClose,
|
||||
onInput = () => {},
|
||||
|
@ -51,14 +50,23 @@ export function IframeEditor( {
|
|||
showBackButton = false,
|
||||
}: IframeEditorProps ) {
|
||||
const [ resizeObserver ] = useResizeObserver();
|
||||
const [ temporalBlocks, setTemporalBlocks ] =
|
||||
useState< BlockInstance[] >( initialBlocks );
|
||||
const [ temporalBlocks, setTemporalBlocks ] = useState< BlockInstance[] >(
|
||||
[]
|
||||
);
|
||||
|
||||
// Pick the blocks from the store.
|
||||
const blocks: BlockInstance[] = useSelect( ( select ) => {
|
||||
return select( productEditorUiStore ).getModalEditorBlocks();
|
||||
}, [] );
|
||||
|
||||
/*
|
||||
* Set the initial blocks from the store.
|
||||
* @todo: probably we can get rid of the initialBlocks prop.
|
||||
*/
|
||||
useEffect( () => {
|
||||
setTemporalBlocks( blocks );
|
||||
}, [] ); // eslint-disable-line
|
||||
|
||||
const { setModalEditorBlocks: setBlocks, setModalEditorContentHasChanged } =
|
||||
useDispatch( productEditorUiStore );
|
||||
|
||||
|
|
Loading…
Reference in New Issue