React router pass props to route component

前端 未结 2 769
耶瑟儿~
耶瑟儿~ 2021-02-06 17:25

I\'m trying to pass props from my app.jsx to one of my route components using react router but I get the following error

TypeError: Cannot read property \

2条回答
  •  名媛妹妹
    2021-02-06 17:45

    does not pass custom props to components. Use render function instead:

     
    } />
    

    As SakoBu mentioned you need to change your constructor:

    constructor(props) {
        super(props);
        this.state = {
            account: this.props.acc,
            ethAddress: this.props.ethAdd
        };
    }
    

提交回复
热议问题