I have a simple App Component as below
import { useSelector, shallowEqual } from 'react-redux';
const App: React.FC = () => {
console.log('im at App')
const currentUser = useSelector((state) => (state.userManagement.user), shallowEqual);
// user is an object
return (
<div className="App">
<header className="App-header">
Hello World
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/users">Users</Link>
</li>
</ul>
</nav>
</header>
</div>
);
}
Whenever I press on "Home" Link and navigate to the component above, I will see Im at App twice? useSelector will cause a second re-render despite I've added shallowEqual. Have I understood the concept of using this shallowEqual wrongly?
UPDATES:
I've added the suggested useEffect to debug and realized that it was being logged one time, but why im at App is being printed twice?
useEffect(() => {
console.log("current user changed", currentUser)
},[currentUser])
