Question: I'm trying to ask for runtime permission in ReactNative, but I'm always getting a "Permission is null" error in device screen.

here is the code:

```
import React, {Component} from 'react';
import {Text, View, StyleSheet, TextInput, Button} from 'react-native';
import {PermissionsAndroid} from 'react-native';

export default class HomeScreen extends React.Component {

  componentDidMount()
  {
    PermissionsAndroid.request(PermissionsAndroid.READ_PHONE_STATE) 
  }

  render () {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>Seja Bem vindo a BBTS!</Text>
        <Text style={styles.paragraph}>
          Matricula: {this.props.navigation.state.params.matricula}
        </Text>
        <Text style={styles.paragraph}>
          Email: {this.props.navigation.state.params.email}
        </Text>
        <Text style={styles.paragraph}>
            imei vem aqui
        </Text>
      </View>
    );
  }
}

```

I already put this on android manifest. My APi target is 26.

Any ideias?

Solution: 

```
async requestPermission() {
    try {
      const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE)

      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log("You can read the phone state")
      } else {
        console.log("permission denied")
      }
    } catch (err) {
      console.warn(err)
    }
  }

  componentDidMount()
  {
    this.requestPermission();
  }

```

Answer: 
> 
> How does it perform a search over all such `i`?
> 
> 
> 

This depends, pretty much on the data structure of the object in which the search is performing on. For example if you have a `list` object, the complexity of membership checking is O(n) and if you have a data structure that uses hashtable accessing its items (the `__getitem__` attribute) such as dictionary or set the complexity is approximately O(1).

So in general for user defined objects it works as it's explained in documentation. For objects without hash table it's a linear search and for objects with hash table its a constant search.
That's exactly how it works. Here's a demonstration using `list`:

```
$ for a in `seq 6`; do python3 -m timeit -s "a = 10**$a" 'a in list(range(a))'; done
1000000 loops, best of 3: 0.84 usec per loop
100000 loops, best of 3: 3.04 usec per loop
10000 loops, best of 3: 57.7 usec per loop
1000 loops, best of 3: 639 usec per loop
100 loops, best of 3: 6.74 msec per loop
10 loops, best of 3: 70.3 msec per loop

```

You can observe the time complexity increasing proportional to the size of the container.