The prop `history` is marked as required in `Router`, but its value is `undefined`. in Router

前端 未结 7 948
甜味超标
甜味超标 2021-01-30 01:50

I am new to ReactJs. This is my code:

var React = require(\'react\');
var ReactDOM = require(\'react-dom\');
var {Route, Router, IndexRoute, hashHistory} = requ         


        
7条回答
  •  轮回少年
    2021-01-30 02:34

    I also write a Login practice. And also meet the same question like you. After a day struggle, I found that only this.props.history.push('/list/') can make it instead of pulling in a lot of plugins. By the way, the react-router-dom version is ^4.2.2. Thanks!

    handleSubmit(e){
        e.preventDefault();
        this.props.form.validateFieldsAndScroll((err,values)=>{
            if(!err){
                this.setState({
                    visible:false
                });
                this.props.form.resetFields();
                console.log(values.username);
                const path = '/list/';
                this.props.history.push(path);
            }
        })
    }

提交回复
热议问题