diff --git a/lib/shared/version-utils.js b/lib/shared/version-utils.js --- a/lib/shared/version-utils.js +++ b/lib/shared/version-utils.js @@ -36,4 +36,31 @@ return true; } -export { FUTURE_CODE_VERSION, NEXT_CODE_VERSION, hasMinCodeVersion }; +function hasMinStateVersion( + platformDetails: ?PlatformDetails, + minStateVersion: $Shape<{ +native: number, +web: number }>, +): boolean { + if (!platformDetails) { + return true; + } + const { stateVersion } = platformDetails; + const minVersion = isWebPlatform(platformDetails.platform) + ? minStateVersion.web + : minStateVersion.native; + + if (!minVersion) { + return true; + } + if (!stateVersion || stateVersion < minVersion) { + return false; + } + + return true; +} + +export { + FUTURE_CODE_VERSION, + NEXT_CODE_VERSION, + hasMinCodeVersion, + hasMinStateVersion, +};