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

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

react.js - react-alert - 未捕獲的不變違規:無效的鉤子調用

react.js - react-alert - 未捕獲的不變違規:無效的鉤子調用

catspeake 2021-10-21 13:25:01
我的react.js應用程序中有這段代碼:import { withAlert} from "react-alert"; class Signup extends React.Component {state={email:'',passwordHash:'',rePasswordHash:''};onButtonClick = () =>{    if(this.state.passwordHash!==this.state.rePasswordHash){        this.props.alert.error("Wrong password");    }    else{        this.props.alert.show("Creating new account");    }};render(){    return(                    <ButtonActor name="Sign In" onButtonClick={this.onButtonClick} />    );}}export default withAlert()(Signup);它在我的SignUp班級中,每當用戶嘗試創建帳戶時,它只需要在兩個字段中輸入的密碼是否相同。據此,它應該創建一個警報。但它正在崩潰并給我這個錯誤:Uncaught Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component.react-alert,我正在使用的庫。任何人都可以幫助我如何解決這個問題?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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