情况是我使用axios来自后端的增益数据,我想从当前页面重定向到另一个页面以及传递一些数据.
我在使用<Redirect>重定向时如何传递数据?
我使用的代码如下,我无法在目标页面获得"个人资料".无论如何,this.props或this.state
我知道使用react-router-redux是一个更好的选择.
import React, { Component } from 'react'
import axios from 'axios'
import { Redirect } from 'react-router'
export default class Login extends Component {
constructor(props) {
super(props)
this.state = {
email: '',
emailError: 'Please fill in email',
password: '',
passwordError: 'Please fill in password',
redirect: false,
profile: ''
}
this.handleEmail = (e) => {
var email = e.target.value
var emailError = ''
if (email === null)
emailError = 'Please …Run Code Online (Sandbox Code Playgroud)