Thanks wzspdw.
I tried attaching the component, but realised my spawned actor did not have a root component. I set the UStaticMeshComponent as the actors root, and it shows in the outliner now,
auto actor = world->SpawnActor(AActor::StaticClass());
auto meshcomponent = NewObject<UStaticMeshComponent>(actor, UStaticMeshComponent::StaticClass());
meshcomponent->OnComponentCreated();
meshcomponent->RegisterComponent();
actor->SetRootComponent(meshcomponent);