forked from kristiansorens/react-native-flag-secure-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (29 loc) · 712 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* @flow */
// Adapted from
// https://github.com/corbt/react-native-keep-awake
import React, { Component } from 'react'
import { NativeModules } from 'react-native'
export default class FlagSecure extends Component {
static isActive = false
static activate () {
if (!FlagSecure.isActive) {
NativeModules.FlagSecure.activate()
FlagSecure.isActive = true
}
}
static deactivate () {
if (FlagSecure.isActive) {
NativeModules.FlagSecure.deactivate()
FlagSecure.isActive = false
}
}
componentWillMount () {
FlagSecure.activate()
}
componentWillUnmount () {
FlagSecure.deactivate()
}
render () {
return this.props.children || null
}
}