为什么CSSTransitionGroup在React Router Link元素上抛出渲染错误?

时间:2017-06-10 23:40:40

标签: reactjs react-router

为什么我在尝试在CSSTransitionGroup react-router组件上设置Link时收到此错误:

invariant.js:44 Uncaught Error: link is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. Check the render method of TransitionGroup.

我的代码是:

return (

        <CSSTransitionGroup component='Link' transitionName='navBarLink' transitionEnterTimeout={300} transitionLeaveTimeout={500}>
            <Link style={linkStyle} to={this.props.pageTo} onClick={this.setActiveState}>
                {this.props.title}
            </Link>
        </CSSTransitionGroup>

    )

1 个答案:

答案 0 :(得分:0)

你导入链接了吗?如果是这样,为什么链接在引号

 component='Link'

不应该

 component=Link