Calvin-Huang / react-native-device-brightness

Screen brightness adjustment tool for ReactNative iOS and Android.
MIT License
49 stars 57 forks source link

Screen Brightness is not persistent #6

Closed JperF closed 7 years ago

JperF commented 7 years ago

I have the following code in my react native component. The screen brightness is not persisting. The screen brightness stays on for approximately 1-2 seconds then returns to the original brightness.

(e, state, context) => {
          console.log(state);
          if (!state.index) {
            DeviceBrightness.getBrightnessLevel()
              .then((luminous) => {
                this.setState({
                  luminous
                }, () => {
                  DeviceBrightness.setBrightnessLevel(1);
                });
              });
          } else {
            DeviceBrightness.setBrightnessLevel(this.state.luminous);
          }
}