Answered step by step
Verified Expert Solution
Question
1 Approved Answer
export default function Category 1 ( ) { const [ selectedFruit , setSelectedFruit ] = useState ( ' select ' ) ; const [ selectedQuantity
export default function Category const selectedFruit setSelectedFruit useStateselect; const selectedQuantity setSelectedQuantity useStatequantity; const totalPrice setTotalPrice useState; const fruitPrices apple: banana: orange: grapes: mango: ; const addToBasket const price fruitPricesselectedFruit; const subtotal price selectedQuantity; const newTotalPrice totalPrice subtotal; setTotalPricenewTotalPrice; console.logAdding $selectedQuantity $selectedFruits to the basket. Total cost: $$newTotalPrice; You can implement the functionality to add to basket here ; return Fruits setSelectedFruititemValue setSelectedQuantityitemValue Total Price: $totalPricetoFixed ; const styles StyleSheet.create fruits: width: height: borderTopLeftRadius: borderTopRightRadius: title: fontSize: fontWeight: 'bold', textAlign: 'center', paddingVertical: ; import Text, View, StyleSheet, Image from 'reactnative'; export default function AssetExample return ; const styles StyleSheet.create container: alignItems: 'center', justifyContent: 'center', padding: backgroundColor: #ecff borderColor: #ecff logo: height: width: marginBottom: ; Use this code to create a Vegetales dropdown on snack expo. In this first dropdown, provide at least vegetables. They should contain values like this: Potato$ Carrot$ At least of the items, should have the same price you can make this up For simplicity reasons, we will assume the price to be a singledigit value without any decimal point.
export default function Category
const selectedFruit setSelectedFruit useStateselect;
const selectedQuantity setSelectedQuantity useStatequantity;
const totalPrice setTotalPrice useState;
const fruitPrices
apple:
banana:
orange:
grapes:
mango:
;
const addToBasket
const price fruitPricesselectedFruit;
const subtotal price selectedQuantity;
const newTotalPrice totalPrice subtotal;
setTotalPricenewTotalPrice;
console.logAdding $selectedQuantity $selectedFruits to the basket. Total cost: $$newTotalPrice;
You can implement the functionality to add to basket here
;
return
Fruits
setSelectedFruititemValue
setSelectedQuantityitemValue
Total Price: $totalPricetoFixed
;
const styles StyleSheet.create
fruits:
width:
height:
borderTopLeftRadius:
borderTopRightRadius:
title:
fontSize:
fontWeight: 'bold',
textAlign: 'center',
paddingVertical:
;
import Text, View, StyleSheet, Image from 'reactnative';
export default function AssetExample
return
;
const styles StyleSheet.create
container:
alignItems: 'center',
justifyContent: 'center',
padding:
backgroundColor: #ecff
borderColor: #ecff
logo:
height:
width:
marginBottom:
;
Use this code to create a Vegetales dropdown on snack expo.
In this first dropdown, provide at least vegetables. They should contain values like this:
Potato$
Carrot$
At least of the items, should have the same price you can make this up
For simplicity reasons, we will assume the price to be a singledigit value without any decimal point.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started