Skip to content

Instantly share code, notes, and snippets.

@clc80

clc80/App.js

Last active Jun 4, 2018
Embed
What would you like to do?
getting text from input field
import React, { Component } from 'react';
import Form from './components/Form'
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
formItems: [],
newFormElement: ''
}
}
handleSubmit(e) {
e.preventDefault();
}
render() {
return (
<div className="App">
<ul>
{this.state.formItems.map( (element, index) =>
<Form
key={index}
formElement={element}
/>
)}
</ul>
<form onSubmit={(e) => this.handleSubmit(e)}>
<input type="text" value={this.state.newFormElement} />
<input type="submit" />
</form>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.