Guest User

Untitled

a guest
Sep 21st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. class App extends React.Component {
  2.  
  3. // You need to define the state in the constructor
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. username: '', // why would Username and Password be booleans?
  8. password: ''
  9. }
  10. this.closeLogin = this.closeLogin.bind(this);
  11. this.handleChange = this.handleChange.bind(this);
  12. this.login = this.login.bind(this); // you don't "do" logins, you "login"
  13. }
  14.  
  15. closeLogin() {
  16. props.openLogin(false);
  17. }
  18.  
  19. handleChange(event, property) {
  20. this.setState({
  21. [prop]: event.target.value
  22. })
  23. }
  24.  
  25. login() {
  26. console.log(props.appId + ' : ' + this.state.username);
  27. }
  28.  
  29. render() {
  30. return (
  31. <Dialog
  32. open={true}
  33. onClose={this.closeLogin}
  34. ariaLabelledBy='form-dialog-title'
  35. >
  36. <DialogContent>
  37. <TextField
  38. fullWidth
  39. require
  40. name="username"
  41. onChange={()=>{this.handleChange('Username')}}
  42. value={this.state.username}
  43. />
  44. <Button onClick={()=>{this.doLogin(appId)}} className={classes.button}>Log Me In</Button>
  45. </DialogContent>
  46. </Dialog>
  47. );
  48. }
  49. }
Add Comment
Please, Sign In to add comment