From d80bc9f45c4ab06a8a8bc38fc436bb5345225514 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sat, 18 Jul 2020 14:51:54 -0700 Subject: refactor newpaste --- frontend/src/components/Inputs.js | 233 +++++++++++++++++--------------------- 1 file changed, 104 insertions(+), 129 deletions(-) (limited to 'frontend/src/components/Inputs.js') diff --git a/frontend/src/components/Inputs.js b/frontend/src/components/Inputs.js index 08cf3fc..a9b08b7 100644 --- a/frontend/src/components/Inputs.js +++ b/frontend/src/components/Inputs.js @@ -15,43 +15,33 @@ const FlexChild = styled.div` margin-left: 2em; ` -class TitleInput extends React.Component { - render() { - return ( - - - - - - ); - } +const TitleInput = (props) => { + return ( + + + + + + ); } -class PasteInput extends React.Component { - - constructor(props) { - super(props) - - this.textArea = React.createRef() - this.handleKeyDown = this.handleKeyDown.bind(this) - } - - handleKeyDown(e) { +const PasteInput = (props) => { + function handleKeyDown(e) { if (e.keyCode === 9) { // tab was pressed // prevent autofocus on next intput @@ -61,96 +51,83 @@ class PasteInput extends React.Component { const start = e.target.selectionStart const end = e.target.selectionEnd - this.props.insertTabCallback(start, end) + props.insertTabCallback(start, end) // set cursor position to be at start e.target.selectionEnd = end + 4; } } - render() { - return ( + return ( + + +