fix: schema should be componentsTree

This commit is contained in:
wuji.xwt 2020-07-28 14:21:27 +08:00
parent 9035a8554c
commit 69a2a8998f

View File

@ -8,7 +8,7 @@ import './index.scss';
const SamplePreview = ({ editor }: PluginProps) => { const SamplePreview = ({ editor }: PluginProps) => {
const [data, setData] = useState({}); const [data, setData] = useState({});
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const handleClick = async () => { async function handleClick() {
if (!editor) { if (!editor) {
return; return;
} }
@ -25,6 +25,10 @@ const SamplePreview = ({ editor }: PluginProps) => {
} }
}; };
function handleClose() {
setVisible(false);
}
const { schema, components } = data; const { schema, components } = data;
return ( return (
<div className="lowcode-plugin-sample-preview"> <div className="lowcode-plugin-sample-preview">
@ -34,11 +38,12 @@ const SamplePreview = ({ editor }: PluginProps) => {
<Dialog <Dialog
visible={visible} visible={visible}
footer={false} footer={false}
onClose={handleClose}
> >
<ReactRenderer {visible && <ReactRenderer
schema={schema} schema={schema.componentsTree[0]}
components={components} components={components}
/> />}
</Dialog> </Dialog>
</div> </div>
); );