Code Monkey home page Code Monkey logo

Comments (8)

viniciusfonseca avatar viniciusfonseca commented on May 27, 2024 3

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.

viniciusfonseca avatar viniciusfonseca commented on May 27, 2024 1

@agarcia17

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.

frangeris avatar frangeris commented on May 27, 2024 1

@agarcia17

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.

Benzer1406 avatar Benzer1406 commented on May 27, 2024 1

Same for me!

from react-native-masked-text.

bhrott avatar bhrott commented on May 27, 2024

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.

bug_input_react_native mov

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.

diegorodriguesvieira avatar diegorodriguesvieira commented on May 27, 2024

Thanks for help! =)

from react-native-masked-text.

agarcia17 avatar agarcia17 commented on May 27, 2024

@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.

agarcia17 avatar agarcia17 commented on May 27, 2024

@viniciusfonseca will try that out! thanks a bunch!

from react-native-masked-text.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.