function App() {
const inputRef = useRef();
const [inputValue, setInputValue] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
setInputValue(inputRef.current.value);
};
return (
<form onSubmit={handleSubmit}>
<h1>{inputValue}</h1>
<TextInput ref={inputRef} />
<button type="submit">Submit</button>
</form>
);
}
export default App;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter