Javascript 虽然道具在渲染中传递,但它不会在路线中传递

Javascript 虽然道具在渲染中传递,但它不会在路线中传递,javascript,reactjs,react-redux,react-router,Javascript,Reactjs,React Redux,React Router,我试图在route组件中传递道具,我知道我们不能直接传递给它,所以我曾经渲染过,但是道具在子组件中仍然没有定义 import React from 'react'; //components import Register from '../components/register/register'; import Login from "../components/login/login"; import ForgetPassword from '../component

我试图在route组件中传递道具,我知道我们不能直接传递给它,所以我曾经渲染过,但是道具在子组件中仍然没有定义

import React from 'react';
//components
import Register from '../components/register/register';
import Login from "../components/login/login";
import  ForgetPassword from '../components/forget-password/forget-password';
//redux
import {store} from "../redux/store";
import { connect } from 'react-redux';
import actions from "../redux/authentication/actions";
//react-router
import {BrowserRouter,Route,Switch} from "react-router-dom";
//antd
import "antd/dist/antd.css";
//css
import '../global/_global.scss';

function Authentication(props) {
  console.log("PROPS", props)
  return (
    <div className="App">
    <BrowserRouter>
      {/*switch-component will render first that matches the includes path*/}
      <Switch>
        <Route  path='/login' component={Login} />
        <Route  exact  path='/' component={Login}  />
        <Route   path='/register'
          render={(props) => (
              <Register {...props} check={props.registerUser}  />
          )}
                   />
        <Route   path='/forget-password' component={ForgetPassword} />
      </Switch>
    </BrowserRouter>
    </div>
  );
}
function mapStateToProps(state){
  return state.reducers;
}
export default connect(mapStateToProps, actions)(Authentication);
从“React”导入React;
//组成部分
从“../components/Register/Register”导入寄存器;
从“./components/Login/Login”导入登录名;
从“../components/forget password/forget password”导入伪造密码;
//重演
从“./redux/store”导入{store};
从'react redux'导入{connect};
从“./redux/authentication/actions”导入操作;
//反应路由器
从“react router dom”导入{BrowserRouter,Route,Switch};
//蚂蚁
导入“antd/dist/antd.css”;
//css
导入“../global/_global.scss”;
功能验证(props){
控制台日志(“道具”,道具)
返回(
{/*开关组件将首先呈现与包含路径*/}
(
)}
/>
);
}
函数MapStateTops(状态){
返回状态。减速器;
}
导出默认连接(MapStateTrops、actions)(身份验证);
尝试这样使用

 return (
    <Route
      render={routeProps => (
        
          <Component {...routeProps} />
       
      )}
    />
  );
返回(
(
)}
/>
);
而不是

return (
        <Route
          render={(routeProps) => (
            
              <Component {...routeProps} />
           
          )}
        />
      );
返回(
(
)}
/>
);

尝试将
render={(props)=>(
更改为
render={()=>(
它正在工作。谢谢,但如果我喜欢,为什么它不工作呢。