java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String when I use a RN switch Android only

Viewed 1113

I keep getting this error in the Android version of my React Native app. The iOS version of the app has zero problems with the React Native switch that I've used. This app is currently running on RN 0.54

Just in case, here's the code that uses the switch:

 <View style={styles.feedbackSwitchWrapper}>
                        <Switch
                            value={this.props.feedbackCancellation}
                            onValueChange={() => {
                                this.feedbackCancellationToggle()
                            }}
                            onTintColor="#xxxx"
                        />
                    </View>

And here is the error I get when I hit the switch. enter image description here

Here's the updated code that ended up fixing the issue:

this.feedbackCancellation = SomeBluetoothEventEmitter.addListener('feedbackMode', event => {
            // console.log('show me feedback mode object: ', event);
            if (!event) {
                return;
            }
            let feedbackCancellation = event.feedbackMode;
            if (this.cancellationFeedbackDeferred) {
                this.cancellationFeedbackDeferred.resolve(event.feedbackMode);
                let trueOrFalseValue = this.convertIntToBool(feedbackCancellation);
                /* 
                NOTE: for both feedbackCancellation and noiseReduction, we are getting the value
                of each FROM THE DEVICE.  We will use setFeedbackCancellationFunc to set the value in PROPS,
                then we will use toggleFeedbackCancellationFunc to TOGGLE the values during
                normal use.  
                */
                this.props.setFeedbackCancellationFunc(trueOrFalseValue);

            } else {
                if (this.mounted === true) { this.setState({ feedbackCancellation }) }
            }
        })
0 Answers
Related