How to stop component going to world root

I just created the same file in a blank project it works as expected once added this line.

Did you try dragging the C++ file directly from ContentBrowser to the scene? (Don’t create BP yet)