I am making a upload product for selling . And I had make a component for receive the input number(units or price) from the user, and in the main page will need to count the total price : units * price … However ,I get stucked here … I don’t know how I am able to get the value from the component …
I have attached my code . Could you please take a look ? Thank you so much !!
Component for putting number
import React from 'react';
import { StyleSheet, View } from 'react-native'
import { TextInput } from 'react-native-gesture-handler';
import colors from '../config/colors';
function TryInputNum({children}) {
return (
<View style={styles.container}>
<TextInput placeholder="Enter a number">{children}</TextInput>
</View>
);
}
const styles = StyleSheet.create({
container :{
width : 150,
height : 200,
backgroundColor : colors.white,
}
})
export default TryInputNum;
The main page
import React from 'react';
import { StyleSheet, View,Text } from 'react-native'
import TryInputNum from '../components/TryInputNum';
import colors from '../config/colors';
function TryCountScreen({children}) {
return (
<View style={styles.container}>
<Text>{children}</Text>
<TryInputNum/>
</View>
);
}
const styles = StyleSheet.create({
container : {
flex :1,
backgroundColor : colors.primary,
justifyContent : 'center',
alignItems : 'center',
}
})
export default TryCountScreen;