Comments (8)
You can prevent this by wrapping the masked text input with a custom component.
Pass a "type" prop to the wrapper component, then at the shouldComponentUpdate lifecycle function return false if the "type" prop equals "masked".
from react-native-masked-text.
class FormField extends React.Component { // wrapper component
maskedInputRef = null
static get TYPE() {
return {
DATE: 'date',
MASKED: 'masked'
}
}
shouldComponentUpdate() {
return this.props.type !== FormField.TYPE.MASKED // return false if type prop equals masked
}
render() {
switch (this.props.type) {
case FormField.TYPE.MASKED:
return <TextInputMask onBlur={this.props.onChange} /> // render TextInputMask here
}
}
}
from react-native-masked-text.
class FormField extends React.Component { // wrapper component maskedInputRef = null static get TYPE() { return { DATE: 'date', MASKED: 'masked' } } shouldComponentUpdate() { return this.props.type !== FormField.TYPE.MASKED // return false if type prop equals masked } render() { switch (this.props.type) { case FormField.TYPE.MASKED: return <TextInputMask onBlur={this.props.onChange} /> // render TextInputMask here } } }
Tested and still getting the ugly effect, @viniciusfonseca do you have any reproducible code without the flicker? 🙏
Thanks
from react-native-masked-text.
Same for me!
from react-native-masked-text.
Hi =)
Sorry, unfortunately, this is a bug of a text-input component of the react-native.
It don't block the controlled input before the state is applied.
I will open an issue to react-native's repository and keep this issue opened for feature fix.
Thanks for report.
from react-native-masked-text.
Thanks for help! =)
from react-native-masked-text.
@viniciusfonseca, do you mind elaborating more on the workaround you mentioned? I can't seem to get it working correctly
from react-native-masked-text.
@viniciusfonseca will try that out! thanks a bunch!
from react-native-masked-text.
Related Issues (20)
- cel-phone is not working on IOS phone?
- getRawValue is not a function HOT 2
- How set 9 as require digit in mask? HOT 1
- Type Money adds zero to the left HOT 4
- Can't remove white spaces separator from the middle of the masked phone number HOT 2
- How to make a mask look like this +7 (___) ___-__-__ HOT 4
- Type Money adds zero to the left when you type fast HOT 2
- Show the delimiter before rather than after the key press
- Using with React-Hook-Form's Controller and validation
- Web: Text cursor goes to the end after editing the middle of an input HOT 2
- How to put two masks in 1 input HOT 1
- Add Placeholder HOT 1
- date-and-time - 2 high severity vulnerabilities HOT 1
- integer and decimal mask
- How to mock react-native-masked-text to work with jest test cases
- Custom mask: '***' accepted white space
- Integração com react_native_masked_input
- Input ref is not correctly typed
- Prefix disappear after clear field
- Render Error: Cannor read property 'defaultValue' of undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-masked-text.