Field won't update
See original GitHub issueIssue Description
Hi there,
I am sure this is my error, but I cannot get my text input to update:
import * as React from 'react'
import Revalidation from 'revalidation'
const SubmitForm = ({
reValidation: { form, validate, valid, errors, validateAll },
onSubmit
}) =>
<form>
<div className="formGroup">
<label>Name</label>
<input
type="text"
value={form.name}
onChange={e => validate('name', e.target.value)}
/>
{errors.name}
</div>
<p>{valid.toString()}</p>
<button onClick={() => validateAll(onSubmit)}>Submit</button>
</form>
const isGreaterThan = a => b => b > a
const ErrorComponent = ({ errorMsgs }) =>
<div className="error">{errorMsgs.shift()}</div>
const validationRules = {
name: [[isGreaterThan(5), `Minimum Name length of 6 is required.`]]
}
const initialState = { name: 'Alex' }
const enhanced = Revalidation(initialState, validationRules, ErrorComponent, {
validateSingle: false
})
const EnhancedSubmitForm = enhanced(SubmitForm)
class SubmitPage extends React.Component<any, any> {
constructor(props) {
super(props)
this.state = { form: { name: 'Alex' } }
}
onSubmit(e) {
e.preventDefault()
alert('submitted')
}
render() {
return (
<EnhancedSubmitForm onSubmit={this.onSubmit} form={this.state.form} />
)
}
}
export default SubmitPage
In the above example, I see the initial value "Alex"
but when I type in that field, nothing happens? Looking at the example, I would have thought reValidate.validate
would in turn update reValidate.form.name
?
I am sure this is my understanding, hopefully I can contribute to the documentation after 😃!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Some fields are updated while other fields are not
Click the Update fields check box, and then click OK. Microsoft Office Word 2007. Click the Microsoft Office Button, and then click Word...
Read more >Word: Fields won't update | CyberText Newsletter
Word: Fields won't update · Press Ctrl+Shift+F11 on the locked field to unlock it. · To unlock ALL fields in the document, press...
Read more >Fields Won't Update when Printing - Word Ribbon Tips
First, try to determine if all the fields fail to automatically update. In other words, if you have 30 fields in your document...
Read more >Solved: Field won't update - ServiceNow Community
I have a custom deal table with a bunch of records with fields that will revert back to the original value after trying...
Read more >Fields within block won't update - Civil 3D - Autodesk Forums
Please check in Options, User Preference tab, Field Update Settings... (lower left of dialog) and make sure appropriate boxes are checked. Tags ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh yeah, that would explain why
validateAll
wasn’t working ha - I movedbutton.onClick
toform.onSubmit
and now I have a nicely validated formSorry, that is another “me” problem. I needed to to be comparing the
length
so I updatedisGreaterThan
toAnd now it all works 🎉