fix render

This commit is contained in:
Rizky 2023-10-31 14:13:13 +07:00
parent 3bab393c5d
commit 7e9efb848a
2 changed files with 8 additions and 18 deletions

View File

@ -1,5 +1,5 @@
import { FC, ReactNode, useEffect, useState } from "react"; import { FC, ReactNode, useEffect, useState } from "react";
import { useGlobal, useLocal } from "web-utils"; import { deepClone, useGlobal, useLocal } from "web-utils";
import { produceCSS } from "../../../utils/css/gen"; import { produceCSS } from "../../../utils/css/gen";
import { IContent } from "../../../utils/types/general"; import { IContent } from "../../../utils/types/general";
import { FNAdv, FNCompDef, FNLinkTag } from "../../../utils/types/meta-fn"; import { FNAdv, FNCompDef, FNLinkTag } from "../../../utils/types/meta-fn";
@ -94,22 +94,11 @@ export const LRenderInternal: FC<{
let props = {} as Record<string, FNCompDef>; let props = {} as Record<string, FNCompDef>;
let cprops = {} as [string, FNCompDef][]; let cprops = {} as [string, FNCompDef][];
if (meta.comp.mcomp) { props = deepClone(
props = meta.comp.mcomp p.comps.all[meta.comp.id]?.content_tree.component?.props || {}
.get("component") );
?.get("props") cprops = Object.entries(props);
?.toJSON() as Record<string, FNCompDef>;
cprops = Object.entries(props).sort((a, b) => {
return a[1].idx - b[1].idx;
});
} else {
props = structuredClone(
p.comps.all[meta.comp.id]?.content_tree.component?.props || {}
);
cprops = Object.entries(props);
}
comp.propval = treePropEval(p, id, cprops, _scopeIndex); comp.propval = treePropEval(p, id, cprops, _scopeIndex);
} }

View File

@ -7,6 +7,7 @@ import { IRoot } from "../../../utils/types/root";
import { fillID } from "../../editor/tools/fill-id"; import { fillID } from "../../editor/tools/fill-id";
import { PG } from "./global"; import { PG } from "./global";
import { PRASI_COMPONENT } from "../../../utils/types/render"; import { PRASI_COMPONENT } from "../../../utils/types/render";
import { deepClone } from "web-utils";
export const scanComponent = ( export const scanComponent = (
item: IRoot | IContent, item: IRoot | IContent,
@ -97,7 +98,7 @@ export const instantiateComp = (
} }
target = mitem.toJSON(); target = mitem.toJSON();
} else { } else {
target = structuredClone(mcomp.item.content_tree); target = deepClone(mcomp.item.content_tree);
mprops = target.component.props || {}; mprops = target.component.props || {};
} }