react and material ui form code example
Example 1: material ui form
<FormControl>
<InputLabel htmlFor="my-input">Email address</InputLabel>
<Input id="my-input" aria-describedby="my-helper-text" />
<FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
</FormControl>
Example 2: Simple form based react material ui
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
const asyncValidate = (values /*, dispatch */) => {
return sleep(1000).then(() => {
// simulate server latency
if (['[email protected]', '[email protected]'].includes(values.email)) {
// eslint-disable-next-line no-throw-literal
throw { email: 'Email already Exists' }
}
})
}
export default asyncValidate