Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3.  
  4. class GivePassword extends React.Component {
  5. state = {
  6. login: false,
  7. }
  8.  
  9. handleClick = (e) => {
  10. if(this.input.value === this.props.pwd) {
  11. this.setState({
  12. login: true,
  13. });
  14. }
  15. }
  16. render() {
  17.  
  18. let text = (
  19. <div>
  20. <input ref={ el => this.input = el} type="password" />
  21. <button onClick={ this.handleClick }>login</button>
  22. </div>
  23. )
  24.  
  25. if(this.state.login) {
  26. text = <p>Jestem!</p>;
  27. }
  28.  
  29. return text;
  30. }
  31. }
  32.  
  33. class App extends React.Component {
  34. render() {
  35. return <GivePassword pwd="12345678" />
  36. }
  37. }
  38.  
  39. document.addEventListener('DOMContentLoaded', function(){
  40. ReactDOM.render(
  41. <App/>,
  42. document.getElementById('app')
  43. );
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement