AnchorLink iteration bug (#5143)

+ close #5129
pull/5153/head
陆离 8 years ago committed by Wei Zhu
parent 04be276513
commit c3102995b3

@ -16,6 +16,7 @@ export interface AnchorLinkProps {
}
export default class AnchorLink extends React.Component<AnchorLinkProps, any> {
static __ANT_ANCHOR_LINK = true;
static contextTypes = {
anchorHelper: React.PropTypes.any,
};

@ -92,7 +92,7 @@ export default class Anchor extends React.Component<AnchorProps, any> {
renderAnchorLink = (child) => {
const { href } = child.props;
if (href) {
if (child.type.__ANT_ANCHOR_LINK && href) {
this.anchorHelper.addLink(href);
return React.cloneElement(child, {
onClick: this.clickAnchorLink,
@ -128,7 +128,7 @@ export default class Anchor extends React.Component<AnchorProps, any> {
<div className={`${prefixCls}-ink`} >
<span className={inkClass} ref="ink" />
</div>
{React.Children.map(this.props.children, this.renderAnchorLink)}
{React.Children.toArray(this.props.children).map(this.renderAnchorLink)}
</div>
</div>
);

Loading…
Cancel
Save