Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React,{Component} from 'react';
- import ReactDOM from 'react-dom';
- import ListItem from './ListItem';
- class NameForm extends React.Component {
- constructor(props) {
- super(props);
- this.state = {value: ''};
- this.tekstas = "1";
- this.handleChange = this.handleChange.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
- }
- handleChange(event) {
- this.setState({value: event.target.value});
- }
- handleSubmit(event) {
- this.tekstas = this.state.value;
- //alert('A name was submitted: ' + this.state.value);
- event.preventDefault();
- }
- render() {
- return (
- <form onSubmit={this.handleSubmit}>
- <label>
- Name:
- <input type="text" value={this.state.value} onChange={this.handleChange} />
- </label><br></br>
- <label>{this.tekstas}</label><br></br>
- <input type="submit" value="Submit" />
- </form>
- );
- }
- }
- ReactDOM.render(
- <NameForm />,
- document.getElementById('app')
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement