import { Dimensions, ScrollView } from "react-native"; import { View } from "react-native-ui-lib"; import React, { useEffect, useRef } from "react"; import AddGroceryItem from "./AddGroceryItem"; import GroceryList from "./GroceryList"; import { useGroceryContext } from "@/contexts/GroceryContext"; const GroceryWrapper = () => { const { isAddingGrocery } = useGroceryContext(); const scrollViewRef = useRef(null); // Reference to the ScrollView useEffect(() => { if (isAddingGrocery && scrollViewRef.current) { scrollViewRef.current.scrollTo({ y: 400, // Adjust this value to scroll a bit down (100 is an example) animated: true, }); } }, [isAddingGrocery]); return ( {!isAddingGrocery && } ); }; export default GroceryWrapper;