example form using React Hooks
import React, { useState } from "react";
const DynamicTitle = () => {
const [title, setTitle] = useState("Hooks are so fun!");
const [inputText, setInputText] = useState("");
const handleChanges = e => {
setInputText(e.target.value);
};
const changeTitle = e => {
e.preventDefault();
setTitle(inputText);
setInputText("");
};
return (
<div className="Wrapper">
<h1 className="Title">{title}</h1>
<form onSubmit={changeTitle}>
<div className="Input">
<input
className="Input-text"
id="input"
name="inputText"
onChange={handleChanges}
placeholder="Create new title"
type="text"
value={inputText}
/>
<label htmlFor="input" className="Input-label">
New title
</label>
</div>
</form>
</div>
);
};
export default DynamicTitle;