Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scope props merge defaultProps #2716

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/renderer-core/src/renderer/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,14 @@ export default function baseRendererFactory(): IBaseRenderComponent {

__createDom = () => {
const { __schema, __ctx, __components = {} } = this.props;
const scope: any = {};
// merge defaultProps
const scopeProps = {
...__schema.defaultProps,
...this.props,
};
const scope: any = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 this.props 的值不对,包含了很多引擎相关的 props,而非用户需要的 props

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原先的实现就是整个 Renderer 实例当作 scope。可以把这一段注释掉,查看一下原先的 scope.props

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那原来的 props 就不正确,多了很多东西。😓

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要么把原来的 props 问题也解决了,要么再单独记录一个 issue,后面解决。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先解决这个问题吧。

props: scopeProps,
};
scope.__proto__ = __ctx || this;

const _children = getSchemaChildren(__schema);
Expand Down
Loading