Structural transformations of solid electrocatalysts and photocatalysts