Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import ReactDOM from 'react-dom';
- class GivePassword extends React.Component {
- state = {
- login: false,
- }
- handleClick = (e) => {
- if(this.input.value === this.props.pwd) {
- this.setState({
- login: true,
- });
- }
- }
- render() {
- let text = (
- <div>
- <input ref={ el => this.input = el} type="password" />
- <button onClick={ this.handleClick }>login</button>
- </div>
- )
- if(this.state.login) {
- text = <p>Jestem!</p>;
- }
- return text;
- }
- }
- class App extends React.Component {
- render() {
- return <GivePassword pwd="12345678" />
- }
- }
- document.addEventListener('DOMContentLoaded', function(){
- ReactDOM.render(
- <App/>,
- document.getElementById('app')
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement