TransformError SyntaxError in react-native

Solution for TransformError SyntaxError in react-native
is Given Below:

I have a react component, which should just return an alert box as shown:

import React from 'react';
import { StyleSheet, Text, View, Alert } from 'react-native';
export default function PhotoHandler() {
    return (
        <View>
        Alert.alert(
          "Success",
          "Take photo",
          [
            {text: "Open Camera"}
          ]
        )
        </View>    
    );
}
const styles = StyleSheet.create({
    container: {
        flex: 1
    }
});

I am calling this component into another component. However, there is a syntax error as below.

TransformError SyntaxError:
     |             {text: "Open Camera"},
     |                  ^

Can’t see what is wrong with syntax.

Alert.alert is a javascript so you need wrap it into {}

    {Alert.alert(
      "Success",
      "Take photo",
      [
        {text: "Open Camera"}
      ]
    )}