- Create Components folder under src folder
- Add PassingParameterViaOnclick.js file and add below Code
import React from "react";
import { Button, Text, View } from "react-native";
const onClickEvent = (id, name) => e => {
alert(id);
alert(name);
};
const PassingParameterViaOnclick = () => {
return (
<View>
<Text>React passing parameter via onclick event </Text>
<Button
title="Submit"
value="buttonValue"
onPress={onClickEvent(10, "Adi")}
/>
</View>
);
};
export default PassingParameterViaOnclick;
- Open App.js file and update code as below\
import React from 'react';
import { View,StyleSheet } from 'react-native';
import PassingParameterViaOnclick from './src/components/PassingParameterViaOnclick'
const App=()=> {
return (
<View style={styles.container}>
<PassingParameterViaOnclick/>
</View>
);
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop:80
},
});
No comments:
Post a Comment