1

我在我的 React Native 应用程序的 Android 版本中不断收到此错误。该应用程序的 iOS 版本与我使用的 React Native 开关的问题为零。这个应用程序目前在 RN 0.54 上运行

以防万一,这里是使用开关的代码:

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

这是我按下开关时遇到的错误。 在此处输入图像描述

这是最终解决问题的更新代码:

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 }) }
            }
        })
4

0 回答 0