If I write onPress below, when I click the button, the console will write test. But if I write onPress(), it writes a test on the console as the page renders. Does writing onPress() have anything to do with iife? Is that why it works without being called the moment the page is rendered?
import React from 'react';
import { Button } from 'react-native';
const Screen = () => {
const onPress = () =>{
console.log('test')
}
return (
<Button title='button' onPress={onPress()}/>
)
};
export default Screen;