The balanced chemical equation for this reaction is:
MgSO$_4$ + 2NaOH → Mg(OH)$_2$ + Na$_2$SO$_4$
In this reaction, magnesium and hydroxide are the reactants, while magnesium hydroxide and sodium sulphate are the products. Sodium and sulphate ions are present in both the reactants and products, and they do not participate in the chemical reaction. Therefore, they are spectator ions.