Permanently add component to blueprint instance c++

Hey,

How would one go about adding a actor component to a blueprint instance, permanently through c++ in edtior(not runtime)?
Currently using NewObject() and RegisterComponent() - but if you create a blueprint child and edit or run the construction script these added components gets removed?

Goal is to be able to add a component to a blueprint instance through an editor module with buttons as opposed to using the “Add Component” button on the details view. Anyone any idea how you could go about it? It’s quite important they do not get removed once you edit anything as the components hold information.

I know the “+ Add Component” button in the DetailsView can do this but I’m not entirely sure how to reproduce it, seems like it’s using SSCSEditor to do this but again not entirely sure how to access it properly.

If there’s no straightforward way of doing it I’m going to have to get them re-add continuously and handle all info in the blueprint instance itself and set it every time in the components but to avoid this and keep it clean I’d like to be able to keep them there permanently.

NOTE: This is meant to be outside the constructor with a function call from an editor module - so using CreateDefaultSubobject does not suffice,

So, after digging into source of the engine and not really finding anything I decided to go on a random search for functions and I suddenly noticed AddInstanceComponent();

This makes the components stay.

To make this work do the following inside an AActor:

UActorComponent* NewComp = NewObject<UActorComponent>(this, *NewName);
NewComp->RegisterComponent();    
this->AddInstanceComponent(NewComp);