How can the routing object of react-router be passed to pure components?


A>B>C 

A
this.props.paramslocation

C
C
cosnt C = (props) =>{
    return()
}

find a method that does not pass layer by layer, and make it available to all components globally

Mar.31,2021

this.$route try


the easiest way is:
you have got pathname .
so:

A = () => {
    <B pathname={this.props.params.pathname}/>
}

B = props => {
    <C pathname={props.pathname}/>
}

C = ({pathname}) => {
    //pathname
}
Menu