Question: 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
