Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

export default function Category 1 ( ) { const [ selectedFruit , setSelectedFruit ] = useState ( ' select ' ) ; const [ selectedQuantity

export default function Category1(){
const [selectedFruit, setSelectedFruit]= useState('select');
const [selectedQuantity, setSelectedQuantity]= useState('quantity');
const [totalPrice, setTotalPrice]= useState(0);
const fruitPrices ={
apple: 2,
banana: 3,
orange: 3,
grapes: 4,
mango: 5
};
const addToBasket =()=>{
const price = fruitPrices[selectedFruit];
const subtotal = price * selectedQuantity;
const newTotalPrice = totalPrice + subtotal;
setTotalPrice(newTotalPrice);
console.log(`Adding ${selectedQuantity} ${selectedFruit}(s) to the basket. Total cost: $${newTotalPrice}`);
// You can implement the functionality to add to basket here
};
return (
Fruits
setSelectedFruit(itemValue)}
>
setSelectedQuantity(itemValue)}
>
Total Price: ${totalPrice.toFixed(2)}
);
}
const styles = StyleSheet.create({
fruits: {
width: '100%',
height: 200,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
},
title: {
fontSize: 20,
fontWeight: 'bold',
textAlign: 'center',
paddingVertical: 10,
},
});
import { Text, View, StyleSheet, Image } from 'react-native';
export default function AssetExample(){
return (
);
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
padding: 5,
backgroundColor: '#ecf0f1',
borderColor: '#ecf0f1',
},
logo: {
height: 200,
width: 340,
marginBottom:45
}
});
Use this code to create a Vegetales dropdown on snack expo.
In this first dropdown, provide at least 5 vegetables. They should contain values like this:
Potato-$5
Carrot-$8
At least 2 of the items, should have the same price (you can make this up).
For simplicity reasons, we will assume the price to be a single-digit value without any decimal point.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

OUTCOME 3 Outline the methods by which firms recruit externally.

Answered: 1 week ago

Question

OUTCOME 2 Outline the methods by which firms recruit internally.

Answered: 1 week ago