From 94aab3b5ef21c753595b2748456134ec9a59d7a0 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sat, 9 May 2020 23:07:12 -0700 Subject: add title component --- frontend/src/components/PasteArea.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'frontend/src/components/PasteArea.js') diff --git a/frontend/src/components/PasteArea.js b/frontend/src/components/PasteArea.js index f7c060c..fb3db64 100644 --- a/frontend/src/components/PasteArea.js +++ b/frontend/src/components/PasteArea.js @@ -1,10 +1,12 @@ import React from 'react'; +import { TitleInput, PasteInput } from './Inputs' class PasteArea extends React.Component { constructor(props) { super(props); this.state = { - value: '' + title: '', + content: '', }; this.handleChange = this.handleChange.bind(this); @@ -12,20 +14,30 @@ class PasteArea extends React.Component { } handleChange(event) { - this.setState({ value: event.target.value }); + const target = event.target; + const name = target.name; + + this.setState({ + [name]: target.value + }); } handleSubmit(event) { - alert('paste content: ' + this.state.value); + console.log(`title: ${this.state.title}`) + console.log(`content: ${this.state.content}`) event.preventDefault(); } render() { return (
-