Cleave value doesn't update
See original GitHub issueI have the following:
<Cleave
options={{date: true, datePattern: ['m', 'd', 'Y']}}
type="text"
value={this.state.initial_details.date}
onChange={ (data) => {
var data = this.state.data;
data.date = data.target.value;
this.setState({ data: data })
}} required />
While this does update my data.date
as I type things into Cleave, if I change my state in an outside function, the input text stays the same in my Cleave text box which makes the end user think that there is data in the state variable when really there isn’t.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
child component prop doesn't update after change on parent ...
I have component let's say "middle" with prop "element" from let's day "top" component - it's object and I use references to populate...
Read more >Custom Directive not working well with last character (cleave ...
I tried to put $emit('update:value', event.target.value) into a nextTick but it doesn't work. Any help ?
Read more >Cleave.js: format input Text Content When You Are Typing
Cleave.js has a simple purpose: to help you format input text content ... How to get ref of cleave instance and call methods...
Read more >Cleave - MTG Keywords Explained - Card Kingdom Blog
The card's total mana value and color are determined by the normal mana cost. For Commander purposes, color identity can be affected by...
Read more >Is it possible to make the answer entry boxes auto-expand ...
I have a constant sum question, and the cleave function works great on the first box, but then doesn't work on the rest...
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 FreeTop 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
Top GitHub Comments
Hi @nosir, I looked at your solution for reseting a cleave input using
setRawValue
. Capturing the cleave instance on initialization seems unnecessary to me when I would expect the value prop on<Cleave />
to be capable of setting the new value.However, I am unable to let the state manager (Redux in my case) to set the value to an empty string because of the following line: https://github.com/nosir/cleave.js/blob/27ebf3b56a03f3539cc33ac057f74b9298aebf0b/src/Cleave.react.js#L34
I am attempting to reset the value back to “” but because of the
newValue !== owner.properties.initValue
check the value does not get set because it is the initial value.The following Sandbox will demonstrate that you are unable to reset the value after entering a value because this line prevents it from being set back to initValue. https://codesandbox.io/s/qqpln35mz9
I am wondering what the purpose of the
newValue !== owner.properties.initValue
check is. If this wasn’t there, consumers would no longer need to manually callsetRawValue
Any update on this?