In my useEffect statement if I put my sort inside of a conditional statement is does not work until useEffect is rendered again. When I move my sort outside of the if statement it renders the first time. Why is this and how do I fix this?
useEffect(() => {
if (sortBy.value === "PRICE_LOW") {
console.log("in Here");
}
flights.sort((a, b) => b.price - a.price);
}, [flights, sortBy]);
}