im passing values using react redux everything is passed but the component i want to render only renders 1 time and when i save my code in vscode (it renders again)the data renders on page like it should
return (
<div className='fav-container' id='favorites'>
{FavoritesData.data.length === 0 ? (
<h5>You Don't Have Any Favorites Yet!</h5>
) : (
<div className="favorites-grid">{FavoritesData.data.map((item) => <Favorite item={item} />)}</div>
)}
<button onClick={() => console.log(FavoritesData.data.length)}></button>
</div>
);
on the log the data updates but the trenary function dont trigger same goes for useEffect
Are you overwriting data or just updating it? If you're just updating in-place, the reference won't change. I don't have quite enough information to make this diagnosis, but I'm suspecting that you're seeing the same behavior in React as you'd see here:
In React, which enforces a functional approach, you'd want to overwrite
FavoritesData.dataentirely, otherwise the reference won't actually change and React will think that it's looking at the exact same array. If you suspect that this is a misdiagnosis or if you still have questions, please post the code that updatesFavoritesData.dataand I'll update my answer.