Add guard against state being set to non-enumerable type.