diff --git a/webclient/src/Submit.js b/webclient/src/Submit.js
index 2a59280..13060e7 100644
--- a/webclient/src/Submit.js
+++ b/webclient/src/Submit.js
@@ -1,23 +1,17 @@
-import React, { Component } from 'react';
-import { withRouter } from 'react-router-dom';
+import React, { useState, useRef } from 'react';
+import { useHistory } from 'react-router-dom';
-class Submit extends Component {
- constructor(props) {
- super(props);
+function Submit() {
+ const [progress, setProgress] = useState(null);
+ const inputRef = useRef(null);
+ const history = useHistory();
- this.state = {
- progress: null,
- };
-
- this.inputRef = React.createRef();
- }
-
- submitArticle = (event) => {
+ const submitArticle = (event) => {
event.preventDefault();
const url = event.target[0].value;
- this.inputRef.current.blur();
+ inputRef.current.blur();
- this.setState({ progress: 'Submitting...' });
+ setProgress('Submitting...');
let data = new FormData();
data.append('url', url);
@@ -26,29 +20,25 @@ class Submit extends Component {
.then(res => res.json())
.then(
(result) => {
- this.props.history.replace('/' + result.nid);
+ history.replace('/' + result.nid);
},
(error) => {
- this.setState({ progress: 'Error' });
+ setProgress('Error');
}
);
}
- render() {
- const progress = this.state.progress;
-
- return (
-
-
- {progress ? progress : ''}
-
- );
- }
+ return (
+
+
+ {progress ? progress : ''}
+
+ );
}
-export default withRouter(Submit);
+export default Submit;