I'm trying to make an e-commerce app using expo with typescript and I'm having issues with loading my categories page.There's two ways which one can access the category page
- Through bottom nav - this one works fine
- Through buttons on the home page
Trying to setState based off the params that's coming in through the homepage but it's giving me the Too many re-renders error.Below is the code that I currently have for it.
The default needs to be there because of the first method of entering the category page, I've tried putting a conditional as the default category, but category wont change the second time if being accessed through the home page again.
export default function CategoryList(props: Props) { let { params } = useRoute<StackRouteProp<'Home'>>() const [currentCategory, setCategory] = useState({categories: Categories[0]}); if (params) { setCategory({categories: params.categories}) }}