Merge branch 'fix/mixed-setter' into 'release/1.0.0'

fix(editor-skeleton): fix dynamic setter support in mixed-setter

问题描述, 满足以下条件时:
1. prototype field 支持变量:`supportVariable = true `
2. setter是函数,且返回值是对象: `{ componentName: string; props: object }`

最终会实例化 MixedSetter,执行 setter 函数,但并未对返回内容做处理。

最终抛出错误:
```
Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {componentName, props}). If you meant to render a collection of children, use an array instead.
```

See merge request !1001278
This commit is contained in:
力皓 2020-09-29 21:53:52 +08:00
commit 519a542c82

View File

@ -207,8 +207,14 @@ export default class MixedSetter extends Component<{
const { setter, props } = currentSetter;
let setterProps: any = {};
let setterType: any;
let dynamicProps: any = {};
if (isDynamicSetter(setter)) {
setterType = setter.call(field, field);
// { componentName: string; props: object }
if (typeof setterType === 'object' && typeof setterType.componentName === 'string') {
dynamicProps = setterType.props || {};
setterType = setterType.componentName;
}
} else {
setterType = setter;
}
@ -224,6 +230,7 @@ export default class MixedSetter extends Component<{
field,
...restProps,
...extraProps,
...dynamicProps,
onInitial: () => {
this.handleInitial(currentSetter);
},