亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法呈現授權頁面

無法呈現授權頁面

叮當貓咪 2023-03-03 15:43:49
我正在嘗試設置 firebase 身份驗證。我有兩個組成部分。第一個是帶有 firebase.auth().currentUser 的應用程序,我正在檢查是否有登錄用戶,然后如果有這樣的用戶,我會呈現頁面,如果沒有,我會呈現登錄頁面。第二個組件我只是從父級獲取處理程序并嘗試呈現登錄頁面?,F在我只看到空白頁和錯誤“'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 關注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號