You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
Toggling torch on/off won't work without remote debugging on.
Happens with Android (7.0)
Not tested with iOS yet
// ...import{RNCamera}from'react-native-camera'classCaptureextendsComponent{constructor(props){super(props)this.toggleTorch=this.toggleTorch.bind(this)this.state={torchON: false}}toggleTorch(){if(this.camera){this.setState({torchON: !this.state.torchON})}}render(){console.log(this.camera)// <--- solved by removing/comment out this line (edited)return(<Viewstyle={localStyle.container}><RNCameraref={camera=>this.camera=camera}style={localStyle.preview}captureAudio={false}flashMode={this.state.torchON ? RNCamera.Constants.FlashMode.torch: RNCamera.Constants.FlashMode.off}permissionDialogTitle={'Permission to use camera'}permissionDialogMessage={'We need your permission to use your camera phone'}/><Viewstyle={localStyle.bottom}><TouchableOpacityonPress={this.toggleTorch}style={localStyle.switch}><Textstyle={{fontSize: 14}}>Torch {this.state.torchON ? "ON" : "OFF"}</Text></TouchableOpacity></View></View>)}}constlocalStyle=StyleSheet.create({container: {flex: 1,backgroundColor: 'black'},preview: {flex: 1,justifyContent: 'flex-end',alignItems: 'center',},bottom:{justifyContent: 'center',},switch: {flex: 0,backgroundColor: '#fff',borderRadius: 5,padding: 15,paddingHorizontal: 20,alignSelf: 'center',margin: 20,}})
The text was updated successfully, but these errors were encountered:
Issue solved.
I feel so stupid to put console.log(this.camera) inside the render function.
I forgot to remove/comment it out causing the app to stuck.
My bad my bad...
Toggling torch on/off won't work without remote debugging on.
Happens with Android (7.0)
Not tested with iOS yet
The text was updated successfully, but these errors were encountered: