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