mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-17 11:13:50 +00:00
Merge branch hotfix/code-generator-initial-state into release/1.0.0
Title: fix: 🐛 schema 中没有 state 的定义, 出码后的 Rax/React 组件应有个默认的空的 state 即使 schema 中没有 state 的定义,根据 React 和 Rax 的 class 组件的规范,也应该有一个空的 state 的 -- 否则在访问数据源, this.state.xxx 或 this.setState 等相关的一些 API 的时候会报错的。 Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/4083908
This commit is contained in:
commit
3853302678
@ -32,8 +32,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
const ir = next.ir as IContainerInfo;
|
const ir = next.ir as IContainerInfo;
|
||||||
const scope = Scope.createRootScope();
|
const scope = Scope.createRootScope();
|
||||||
|
|
||||||
if (ir.state) {
|
const state = ir.state || {};
|
||||||
const state = ir.state;
|
|
||||||
const fields = Object.keys(state).map<string>((stateName) => {
|
const fields = Object.keys(state).map<string>((stateName) => {
|
||||||
// TODO: 这里用什么 handlers?
|
// TODO: 这里用什么 handlers?
|
||||||
const value = generateCompositeType(state[stateName], scope);
|
const value = generateCompositeType(state[stateName], scope);
|
||||||
@ -58,7 +57,6 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// TODO: hooks state??
|
// TODO: hooks state??
|
||||||
}
|
|
||||||
|
|
||||||
return next;
|
return next;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,8 +32,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
const ir = next.ir as IContainerInfo;
|
const ir = next.ir as IContainerInfo;
|
||||||
const scope = Scope.createRootScope();
|
const scope = Scope.createRootScope();
|
||||||
|
|
||||||
if (ir.state) {
|
const state = ir.state || {};
|
||||||
const { state } = ir;
|
|
||||||
const fields = Object.keys(state).map<string>((stateName) => {
|
const fields = Object.keys(state).map<string>((stateName) => {
|
||||||
const value = generateCompositeType(state[stateName], scope);
|
const value = generateCompositeType(state[stateName], scope);
|
||||||
return `${stateName}: ${value},`;
|
return `${stateName}: ${value},`;
|
||||||
@ -56,8 +55,6 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsVar]],
|
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsVar]],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return next;
|
return next;
|
||||||
};
|
};
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import __$$projectUtils from '../../utils';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
class Home$$Page extends Component {
|
class Home$$Page extends Component {
|
||||||
|
state = {};
|
||||||
|
|
||||||
_methods = this._defineMethods();
|
_methods = this._defineMethods();
|
||||||
|
|
||||||
_context = this._createContext();
|
_context = this._createContext();
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import __$$projectUtils from '../../utils';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
class Home$$Page extends Component {
|
class Home$$Page extends Component {
|
||||||
|
state = {};
|
||||||
|
|
||||||
_methods = this._defineMethods();
|
_methods = this._defineMethods();
|
||||||
|
|
||||||
_context = this._createContext();
|
_context = this._createContext();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user