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 <component> init error #271

Closed
wants to merge 1 commit into from
Closed

fix <component> init error #271

wants to merge 1 commit into from

Conversation

xlshen
Copy link

@xlshen xlshen commented Nov 23, 2017

Warning: The tag is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 81.53% when pulling ddd2625 on xlshen:master into f8b12cd on weui:master.

@xlshen xlshen mentioned this pull request Nov 24, 2017
@yeeez
Copy link

yeeez commented Mar 11, 2018

我觉得应该是先判断是否有传入props.component,如果没有,用FlexItem.defaultProps中的值,也就是div来作为component,如果有传入,则直接使用参数,比如span来作为compoent。难道直接使用Componet就可以达到这个效果?

@xlshen
Copy link
Author

xlshen commented Mar 13, 2018

@yeeez 根本原因在react编译时把component当作普通标签处理了,而不是变量处理:

<component className="weui-flex__item" {...others}>
  { children }
</component>

处理结果:

var FlexItem = function FlexItem(props) {
    var component = props.component,
        children = props.children,
        others = objectWithoutProperties(props, ['component', 'children']);

    return React__default.createElement(
        'component',  // 此处应该为component变量,而非字符串
        _extends({ className: 'weui-flex__item' }, others),
        children
    );
};

so...悲剧出现了

可以通过pull requests文件中修改办法解决该问题

@yeeez
Copy link

yeeez commented Mar 13, 2018

@xlshen tks,感觉项目停了,请求都没有受理

Copy link

@tsheng tsheng left a comment

Choose a reason for hiding this comment

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

Looks goods. Please go ahead to approve this PR. Thanks.

@z2014
Copy link
Collaborator

z2014 commented Sep 2, 2019

#310

@z2014 z2014 closed this Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants