Stuck in React: Authorization Form Tutorial

Got down to about the 7 part of this tutorial. I think I’ve got all the code correct…but obviously not, but right now my code isn’t displaying anything. When I try to Inspect the consolel does not display any errors. Not sure where I went wrong.

import React from 'react'; import ReactDOM from 'react-dom'; class Contact extends React.Component { constructor(props) { super(props); this.state = { password: 'swordfish', authorized: false }; this.authorize = this.authorize.bind(this); } authorize(e) { const password = e.target.querySelector( 'input[type="password"]').value; const auth = password == this.state.password; this.setState({ authorized: auth }); } render() { const login ( <form action="#"> <input type="password" placeholder="Password"/> <input type="submit" /> </form>); const contactInfo ( <ul> <li> client@example.com </li> <li> 555.555.5555 </li> </ul> ); return ( <div id="authorization"> <h1> { this.state.authorized ? 'Contact' : 'Enter the Password'} </h1> { this.state.authorized ? contactInfo : login } </div> ); } } ReactDOM.render( <Contact />, document.getElementById('app') );

Hi Phil,
have a close look at the syntax of your variable declarations inside the render method. In the Codebyte, syntax errors are already highlighted.

Thank you. That did it.

1 Like

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