How to instantiate using New Object?

This subject seems to have gotten a little murky since Construct Object was depreciated.

What is the correct way to use New Object to spawn a new instance of a UClass? I’m trying to build a custom factory for dynamically creating actor components at run time.

Library.h

UFUNCTION(BlueprintCallable, Category="WhyUNoSpawnOutsideActor")
	static void SpawnActorComponentFromClass(UClass *actorComponent, class AActor *Owner);

Library.cpp

void UApolloLibrary::SpawnActorComponentFromClass(UClass *actorComponent, class AActor *Owner)
{
   NewObject(Owner, actorComponent);
   //Owner->AddOwnedComponent(SpawnedComponent);
}

try this:
.h

UFUNCTION(BlueprintCallable, Category = "WhyUNoSpawnOutsideActor")
	static void SpawnActorComponentFromClass(TSubclassOf<class UActorComponent> ComponentClass, AActor* Owner);

.cpp
{

UWorld* World = Owner->GetWorld();

UActorComponent* NewComp = NewObject<UActorComponent>(Owner, ComponentClass);
NewComp->RegisterComponentWithWorld(World);

}

I’m not sure that you need to register it, please try and let me know.