title: Expo-camera in React Native does not working correclty
body: <p>I am trying to access camera using React native app. I have copied all the code from official documentation. Every one has done the same including the official expo-docs <a href="https://docs.expo.io/versions/latest/sdk/camera/" rel="nofollow noreferrer">https://docs.expo.io/versions/latest/sdk/camera/</a>. My code to access the camera and take picture is </p>
  
  <pre><code>export default function Cameracontrol() {
  
          const [hasPermission, setHasPermission] = useState(null);
          const [type, setType] = useState(Camera.Constants.Type.back);
  
  
          async function takePicture() {
  
              console.log(this.camera)
              if (this.camera) {
                  console.log('Pictactue Taken')
                  let photo = await this.camera.takePictureAsync();
              }
              else {
                  console.log('Caera Not Open');
  
              }
          }
  
  
          useEffect(() =&gt; {
              (async () =&gt; {
                  const { status } = await Camera.requestPermissionsAsync();
                  setHasPermission(status === 'granted');
              })();
          }, []);
  
          if (hasPermission === null) {
              return &lt;View /&gt;;
          }
          if (hasPermission === false) {
              return &lt;Text&gt;No access to camera&lt;/Text&gt;;
          }
  
          return (
              &lt;View style={{ flex: 1 }}&gt;
                  &lt;Camera style={{ flex: 1 }} type={type}
                  ref={camera =&gt; this.camera = camera}
                  &gt;
                      &lt;View
                          style={{
                              flex: 1,
                              backgroundColor: 'transparent',
                              flexDirection: 'row',
                          }}&gt;
  
                          &lt;View style={{ flex: 1, flexDirection: "row", justifyContent: "space-between", margin: 20 }}&gt;
  
                              &lt;TouchableOpacity
  
                                  style={{
                                      alignSelf: 'flex-end',
                                      alignItems: 'center',
                                      backgroundColor: 'transparent',
                                  }}
                                  onPress={() =&gt; {
                                      setType(
                                          type === Camera.Constants.Type.back
                                              ? Camera.Constants.Type.front
                                              : Camera.Constants.Type.back
                                      );
                                  }}&gt;
                                  &lt;Ionicons
                                      name="ios-photos"
                                      style={{ color: "#fff", fontSize: 40 }}
                                  /&gt;
  
                              &lt;/TouchableOpacity&gt;
                              &lt;TouchableOpacity
                                  onPress={takePicture}
                                  style={{
                                      alignSelf: 'flex-end',
                                      alignItems: 'center',
                                      backgroundColor: 'transparent',
                                  }}&gt;
                                  &lt;FontAwesome
                                      name="camera"
                                      style={{ color: "#fff", fontSize: 40 }}
                                  /&gt;
                              &lt;/TouchableOpacity&gt;
                              &lt;TouchableOpacity
                                  style={{
                                      alignSelf: 'flex-end',
                                      alignItems: 'center',
                                      backgroundColor: 'transparent',
                                  }}&gt;
                                  &lt;MaterialCommunityIcons
                                      name="camera-switch"
                                      style={{ color: "#fff", fontSize: 40 }}
                                  /&gt;
                              &lt;/TouchableOpacity&gt;
                          &lt;/View&gt;
                      &lt;/View&gt;
                  &lt;/Camera&gt;
              &lt;/View&gt;
          );
      }
  </code></pre>
  
  <p>I am experiencing the following error.</p>
  
  <pre><code>undefined is not an object (evaluating '_this.camera = camera')
  </code></pre>
  
  <p>this error is strongly related with the line</p>
  
  <pre><code>ref={camera =&gt; this.camera = camera}
  </code></pre>
  
  <p>By removing this line of code the error is also removing.</p>
  
  <p>I would really really appreciate if some boy would help me with this.</p>