mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 08:58:15 +00:00
fix: 修复在 tsx 文件中使用渲染器 ts 报错问题
This commit is contained in:
parent
5fec8f2697
commit
9afa0771d1
@ -1,4 +1,4 @@
|
||||
import React, { Component, PureComponent, createElement, createContext, forwardRef } from 'react';
|
||||
import React, { Component, PureComponent, createElement, createContext, forwardRef, ReactInstance, ContextType } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import {
|
||||
adapter,
|
||||
@ -8,6 +8,7 @@ import {
|
||||
addonRendererFactory,
|
||||
tempRendererFactory,
|
||||
rendererFactory,
|
||||
types,
|
||||
} from '@ali/lowcode-renderer-core';
|
||||
import ConfigProvider from '@alifd/next/lib/config-provider';
|
||||
|
||||
@ -36,8 +37,23 @@ adapter.setConfigProvider(ConfigProvider);
|
||||
|
||||
function factory() {
|
||||
const Renderer = rendererFactory();
|
||||
return class ReactRenderer extends Renderer {
|
||||
constructor(props: any, context: any) {
|
||||
return class ReactRenderer extends Renderer implements Component {
|
||||
readonly props: types.IProps;
|
||||
|
||||
context: ContextType<any>;
|
||||
|
||||
setState: (
|
||||
state: types.IState,
|
||||
callback?: () => void,
|
||||
) => void;
|
||||
|
||||
forceUpdate: (callback?: () => void) => void;
|
||||
|
||||
refs: {
|
||||
[key: string]: ReactInstance,
|
||||
};
|
||||
|
||||
constructor(props: types.IProps, context: ContextType<any>) {
|
||||
super(props, context);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import contextFactory from '../context';
|
||||
import { isFileSchema, goldlog } from '../utils';
|
||||
import baseRendererFactory from './base';
|
||||
import divFactory from '../components/Div';
|
||||
import { IProps } from '../types';
|
||||
import { IProps, ISchema, IState } from '../types';
|
||||
|
||||
export default function rendererFactory() {
|
||||
const { createElement, Component, PureComponent, findDOMNode } = adapter.getRuntime();
|
||||
@ -46,12 +46,14 @@ export default function rendererFactory() {
|
||||
return class Renderer extends Component {
|
||||
static dislayName = 'renderer';
|
||||
|
||||
static defaultProps = {
|
||||
state: IState = {};
|
||||
|
||||
static defaultProps: IProps = {
|
||||
appHelper: null,
|
||||
components: {},
|
||||
designMode: '',
|
||||
suspended: false,
|
||||
schema: {},
|
||||
schema: {} as ISchema,
|
||||
onCompGetRef: () => { },
|
||||
onCompGetCtx: () => { },
|
||||
};
|
||||
|
||||
@ -1,15 +1,22 @@
|
||||
export interface IProps {
|
||||
appHelper: any;
|
||||
components: { [key: string]: any };
|
||||
componentsMap: { [key: string]: any };
|
||||
designMode: string;
|
||||
suspended: boolean;
|
||||
schema: ISchema;
|
||||
onCompGetRef: (schema: ISchema, ref: any) => void;
|
||||
onCompGetCtx: (schema: ISchema, ref: any) => void;
|
||||
customCreateElement: (...args: any) => any;
|
||||
notFoundComponent: any;
|
||||
faultComponent: any;
|
||||
components: { [key: string]: any };
|
||||
className?: string;
|
||||
locale?: string;
|
||||
appHelper?: any;
|
||||
componentsMap?: { [key: string]: any };
|
||||
designMode?: string;
|
||||
suspended?: boolean;
|
||||
onCompGetRef?: (schema: ISchema, ref: any) => void;
|
||||
onCompGetCtx?: (schema: ISchema, ref: any) => void;
|
||||
customCreateElement?: (...args: any) => any;
|
||||
notFoundComponent?: any;
|
||||
faultComponent?: any;
|
||||
}
|
||||
|
||||
export interface IState {
|
||||
engineRenderError?: boolean;
|
||||
error?: Error
|
||||
}
|
||||
|
||||
export interface IRendererProps {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user