Don’t quote me, but from memory you need to get the static mesh from the component and then get/set the material rather than directly on the instanced mesh component.
apologies I realised you’re probably talking c++. Same concept though
component->GetStaticMesh()->SetMaterial(0, MyMaterial);