From e58b453f24c8b4081361112862d29c34eb22009d Mon Sep 17 00:00:00 2001 From: Melonai Date: Wed, 20 May 2020 19:52:18 +0200 Subject: port to react and better error handling in backend --- client/src/Components/Form.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 client/src/Components/Form.js (limited to 'client/src/Components/Form.js') diff --git a/client/src/Components/Form.js b/client/src/Components/Form.js new file mode 100644 index 0000000..4d10f98 --- /dev/null +++ b/client/src/Components/Form.js @@ -0,0 +1,33 @@ +import React, {useState} from 'react'; +import Button from './Button'; +import isURL from "validator/lib/isURL"; + +function Form(props) { + const [state, setState] = useState({value: '', valid: false}); + + const handleSubmit = () => { + if (state.valid) { + props.addRequest(state.value); + } + }; + + const handleChange = (e) => { + const userInput = e.target.value; + const valid = isURL('https://' + userInput); + setState({value: userInput, valid: valid}); + }; + + return ( +
e.preventDefault()}> +
+
+ https:// + +
+
+
+ ) +} + +export default Form; \ No newline at end of file -- cgit 1.4.1