When metals react with non-metals, electrons are transferred from the metal atoms to the non-metal atoms, forming ions. ... Consider reactions between metals and non-metals, for example, Sodium + chlorine = sodium chloride. Magnesium + oxygen = magnesium oxide.
I hope this answers your question