I am trying to generate components from a JSON file with React-Native, and am wondering what is the best way to pass a function to a component as a prop?
Example, button requires the prop onPress, so is there a way to pass in a function to the object onPress as I have done here:
{
component: "Button",
props: {
title: "This is the Title",
onPress: {() => {Alert.alert("Tapped!")}}
}
}
As this generates an unexpected token error, what is a better way to accomplish this?