I have two functional components. The only difference between them is that one is named. Like this:
const one = (props) => (<div>i am the first one</div>);
switch (type) {
case 1:
return one;
case 2:
return (props) => (<div>i am the second one</div>);
}
So the problem is the behavior is not the same. When the named component just rerenders itself after props change, the anonymous component recreates itself (call componentDidMount and componentDidUnmount). Could anyone explain what's happening there?