Skip to content

Instantly share code, notes, and snippets.

@gunar
Created Apr 3, 2019
Embed
What would you like to do?
How to Reset Forms in React.
import React, { useState } from 'react'
const Form = () => {
const [key, setKey] = useState(0)
return (
<div key={key}>
<input type='text' />
<button onClick={/* ... */}>Submit</button>
<button onClick={() => { setKey(key + 1) }}>Reset</button>
</div>
)
}
export {
Form,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment