为了账号安全,请及时绑定邮箱和手机立即绑定

无法呈现授权页面

无法呈现授权页面

叮当猫咪 2023-03-03 15:43:49
我正在尝试设置 firebase 身份验证。我有两个组成部分。第一个是带有 firebase.auth().currentUser 的应用程序,我正在检查是否有登录用户,然后如果有这样的用户,我会呈现页面,如果没有,我会呈现登录页面。第二个组件我只是从父级获取处理程序并尝试呈现登录页面。现在我只看到空白页和错误“'props' 未定义”。请帮我解决它。应用程序.jsimport React, {Component} from "react";import {    BrowserRouter as Router,    Switch,    Route,    Link} from "react-router-dom";import { Layout } from 'antd';import AddStock from './components/stocksDB/addStock';import { Typography, Menu } from 'antd';import 'antd/dist/antd.css';import './App.css';import AddClient from './components/clients/addClient.js';import PifForm from './components/clients/pif/pifForm';import KuaForm from './components/clients/pif/kuaForm';import firebase from './firebase.js';import {Login} from './components/login.js'const { Title } = Typography;const {Header, Footer, Content} = Layout;class App extends Component {    constructor(props){        super(props);        this.state = {            login: '',            password: ''        }    }    handleChange = (event) => {        const target = event.target;        const name = target.name;        this.setState({            [name]: target.value        }, () => {console.log(name, this.state)})    };    signUp = () => {        firebase.auth().createUserWithEmailAndPassword(this.state.login, this.state.password).catch(function(error) {            console.log(error);        })    };    signIn = () => {        firebase.auth().signInWithEmailAndPassword(this.state.login, this.state.password).catch(function(error) {            console.log(error);        })    };    onFinishFailed = errorInfo => {        console.log('Failed:', errorInfo);    };
查看完整描述

2 回答

?
慕莱坞森

TA贡献1810条经验 获得超4个赞

由于Login是功能组件,您需要像这样传入并定义道具:const Login = (props) => {props.handleChange然后,您可以使用和访问道具props.signUp

无需在功能组件内部未定义的this基于类的组件中使用 like 。this


查看完整回答
反对 回复 2023-03-03
?
达令说

TA贡献1821条经验 获得超6个赞

你正在调用 props 但你还没有在你的功能组件中定义它。

export const Login = (props) => {
...

}


查看完整回答
反对 回复 2023-03-03
  • 2 回答
  • 0 关注
  • 177 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号