<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
const { useState, useRef } = React
const [itemsToShow, setItemsToShow] = useState(5);
const [items, setItems] = useState(['Laptop', 'Mobile', 'Backpack', 'Sunglasses', 'Water bottle', 'Headphones', 'Wallet', 'Umbrella', 'Notebook', 'Pen', 'Charger', 'Watch', 'Socks', 'Shoes', 'Jacket', 'Hat', 'Gloves', 'Towel', 'Sunscreen', 'Snacks', 'Map', 'First aid kit', 'Camera', 'Toothbrush', 'Toothpaste', 'Shampoo', 'Conditioner', 'Soap', 'Tissues', 'Hand sanitizer', 'Passport', 'Travel pillow', 'Blanket', 'Earplugs', 'Phone charger', 'Power bank', 'Sunglasses case', 'ID card', 'Cash', 'Credit cards', 'Earbuds', 'Lip balm', 'Hairbrush', 'Hair ties', 'Deodorant', 'Medications', 'Insect repellent'])
const newItemRef = useRef(null);
const scrollToLastItem = () => {
if (newItemRef.current) {
newItemRef.current.scrollIntoView({ behavior: 'smooth' });
const incrementItemsToShow = () => {
setItemsToShow(itemsToShow + 1);
<div className='container'>
<div className='fixed-buttons'>
<button onClick={scrollToLastItem}>Scroll to Last Item</button>
<button onClick={incrementItemsToShow}>Show More Items</button>
{items.slice(0, itemsToShow).map((item, index) => (
<li key={index} ref={index === itemsToShow - 1 ? newItemRef : null}>
ReactDOM.render(<App />, document.getElementById("app"));
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24);
/* Add padding to space the buttons */
background-color: #007BFF;
transition: background-color 0.3s ease;
background-color: #0056b3;
background-color: #f9f9f9;
/* Scroll Animation (Optional) */
@keyframes scrollAnimation {
transform: translateY(-20px);
transform: translateY(0);
/* Apply the animation to the last item when scrolling */
animation: scrollAnimation 0.5s ease;