APSL/react-native-button

isLoading and isDisabled is not working

Closed this issue · 6 comments

Hi,

thx for this great Button. I have a question about the functionality of "isDisabled" and "isLoading". It won't work for me when I'm doing this:

...
var isLoading = false;
export default class extends React.Component
...
return (
            <View style={styles.container}>
                <View style={styles.input}>
                    ...
                    <Button
                        onPress={this._onLoginPressed.bind(this)}
                        isDisabled={isLoading}
                        isLoading={isLoading}>
                        Login
                    </Button>
                </View>
            </View>
        );
    }

If I press the button, my variable "isLoading" gets true but the button is still enabled. What am I doing wrong here?

Hello @albo1337!

Please try to use one or another, not both props. It's fine to use just isLoading prop because it will disable the button.

Please let me know if you need something else.

This is not working. Have tested it too.

It's strange because I'm running this example and the button gets disabled. We currently have this component into 5 different apps and it's working. Can you try to console.log() the value of the isLoading variable inside the render() method?

it works... My fault sorry.

Thank you very much!

Cool! Keep in mind that in order to trigger the render() event, there must be a change of state or props in your component. Using a global var will only work once.

This is exactly the answer I've needed. Thank you very much you helped me a lot!