Forget password in React JS

前端 未结 1 1561
旧时难觅i
旧时难觅i 2021-01-28 18:34

In my log in page I have a button \"Forget my password\", I need, when I click in this button to go to the correct page.

In my current code, when I clic

1条回答
  •  后悔当初
    2021-01-28 19:19

    Please try this example:

    import React from "react";
    
    export default class Login extends React.Component {
        constructor(props) {
            super(props);
            this.state = {forgot: false};
        }
    
        login() {
            alert('Login will work here');
        }
        forgot() {
            this.setState({forgot: true})
        }
    
        render() {
            return (
                
    {this.state.forgot === false &&
    Username:
    Password:
    } {this.state.forgot === true && }
    ); } } class ForgotPassword extends React.Component { reset() { alert('Password is sent to your email'); } render() { return (

    Write your email

    ) } }

    0 讨论(0)
提交回复
热议问题