You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
625 B

import React, { useState } from "react";
import AddToCart1 from "./AddToCart1";
import AddToCart2 from "./AddToCart2";
function AddToCart() {
const list = {
1: <AddToCart1 />,
2: <AddToCart2 />,
};
const [type, setType] = useState(1);
return (
<div className="w-full flex flex-col items-center">
<select
className="mb-10 w-20 bg-gray-200"
onChange={(e) => setType(e.target.value)}
>
{Object.keys(list).map((option, index) => (
<option key={index}>{option}</option>
))}
</select>
{list[type]}
</div>
);
}
export default AddToCart;