Passing props to React Router children routes

后端 未结 3 900
时光说笑
时光说笑 2020-12-08 20:27

I\'m having trouble overcoming an issue with react router. The scenario is that i need to pass children routes a set of props from a state parent component and route.
wh

3条回答
  •  隐瞒了意图╮
    2020-12-08 21:01

    In child component, insted of

    return 
    {this.props.children}

    You may merge props with parent

    var childrenWithProps = React.cloneElement(this.props.children, this.props);
    return 
    {childrenWithProps}

提交回复
热议问题