React Project 'Authorization Form' problem


I’m tackling this project (

My final code is this, but when I click the submit button after entering the right password - nothing changes (no contacts are displayed). When I change authorized to true manually - it’s displayed. Can anyone see the problem??? :slight_smile:

import React from 'react';
import ReactDOM from 'react-dom';

class Contact extends React.Component {
  constructor(props) {
    this.state = {
      password: 'swordfish',
      authorized: false
    this.authorize = this.authorize.bind(this);

  authorize(e) {
    const password =
    const auth = password == this.state.password;
      authorized: auth

  render() {
    let login = (
      <form action="#">
          <input type="password" placeholder='Password' />
          <input type='submit' onSubmit={this.authorize} />
    const contactInfo = (
    return (
      <div id="authorization">
        <h1>{this.state.authorized ? 'Contact': 'Enter the Password'} </h1>
        {this.state.authorized ? contactInfo : login}

  <Contact />, 

Hello, @ajax8982210598, and welcome to the forums!

When you click the button nothing happens. What part of your code controls what is supposed to happen when the button is clicked? Hint: You may want to review instruction #8.

Thanks for the reply and a hint! I found the problem: submit event has to be assigned on the form, not input :slight_smile:

      <form action="#" onSubmit={this.authorize}>
          <input type="password" placeholder='Password' />
          <input type='submit' />
1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.