C++ Adding a static mesh doesn't appear in editor

You don’t need UStaticMesh because UStaticMeshComponent has its own UStaticMesh, and it seems that in your case when you edit MeshComponent in the editor, this part

MeshComponent->SetStaticMesh(StaticMesh);

overrides it. Just try to remove it