How can react-route pass parameters to components without redux?


class Home extends Component {

    constructor(props) {
        super(props)
    }

    doSomething() {
        
    }

    render() {
        return (
            <div>
                <Child onDoSomething={this.doSomething} />
            </div>
        );
    }
}

HomedoSomethingChildreduxredux
class Home extends Component {

    constructor(props) {
        super(props)
    }

    doSomething() {

    }

    render() {
        return (
            <div>
                <Route path="/child" component={Child} />
            </div>
        );
    }
}

Mar.10,2021

you can load subcomponents as render on Route , so you can pass your functions and so on.


class Home extends Component {

    constructor(props) {
        super(props)
    }

    doSomething() {

    }

    render() {
        return (
            <div>
                <Auth path='/user' component={User} onDoSomething={this.doSomething} />
            </div>
        );
    }
}



class Auth extends Component {

    constructor(props) {
        super(props)

    }

    render() {

        let { component: Part, ...rest } = this.props

        
        return (
            <div>
                <Route {...rest} render={(props) => {
                    // restonDoSomethingUser<Part {...rest} {...props} />
                    return (
                        true ? <Part {...rest} {...props} /> : <Redirect to={{pathname: '/login', state: {from: props.location }}} />
                    )

                }} />
            </div>
        );
    }
}


MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e870e4-e2a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e870e4-e2a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?