Open michaelVictoriaDev opened 3 years ago
my snippet code
constructor(props) { super(props); this.state = { // bluetooth devices: null, pairedDs: [], foundDs: [], bleOpend: false, loading: true, boundAddress: '', debugMsg: '' }; } <Switch value={this.state.bleOpend} onValueChange={(v) => { console.log('bleOpend', this.state.bleOpend) console.log('VVVVVVVm', !v) if (!v) { console.log('WHY TRUE') BluetoothManager.disableBluetooth().then(() => { this.setState({ bleOpend: false, loading: false, foundDs: [], pairedDs: [] }); }, (err) => { alert(err) }); } else { console.log('WHY FALSE') BluetoothManager.enableBluetooth().then((r) => { debugger var paired = []; if (r && r.length > 0) { for (var i = 0; i < r.length; i++) { try { paired.push(JSON.parse(r[i])); } catch (e) { //ignore } } } this.setState({ bleOpend: true, loading: false, pairedDs: paired }) }, (err) => { this.setState({ loading: false }) alert(err) }); } }} />
the output
my snippet code
the output![ezgif com-video-to-gif (2)](https://user-images.githubusercontent.com/44763288/92427149-50ce5080-f1be-11ea-92c5-50fdf566dbc6.gif)