MCPcopy
hub / github.com/alibaba/lowcode-engine / render

Method render

packages/renderer-core/src/renderer/renderer.tsx:138–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 }
137
138 render() {
139 const { schema, designMode, appHelper, components } = this.props;
140 if (isEmpty(schema)) {
141 return null;
142 }
143 // 兼容乐高区块模板
144 if (schema.componentName !== 'Div' && !isFileSchema(schema)) {
145 logger.error('The root component name needs to be one of Page、Block、Component, please check the schema: ', schema);
146 return '模型结构异常';
147 }
148 debug('entry.render');
149 const allComponents = { ...RENDERER_COMPS, ...components };
150 let Comp = this.getComp();
151
152 if (this.state && this.state.engineRenderError) {
153 return createElement(this.getFaultComponent(), {
154 ...this.props,
155 error: this.state.error,
156 });
157 }
158
159 if (Comp) {
160 return createElement(AppContext.Provider, {
161 value: {
162 appHelper,
163 components: allComponents,
164 engine: this,
165 },
166 }, createElement(ConfigProvider, {
167 device: this.props.device,
168 locale: this.props.locale,
169 }, createElement(Comp, {
170 key: schema.__ctx && `${schema.__ctx.lceKey}_${schema.__ctx.idx || '0'}`,
171 ref: this.__getRef,
172 __appHelper: appHelper,
173 __components: allComponents,
174 __schema: schema,
175 __designMode: designMode,
176 ...this.props,
177 })));
178 }
179 return null;
180 }
181 };
182}

Callers

nothing calls this directly

Calls 4

getCompMethod · 0.95
getFaultComponentMethod · 0.95
isFileSchemaFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected