@@ -16,14 +16,18 @@ const PlatformDropdown: FC = () => {
1616 const { architecture, bitness } = useClientContext ( ) ;
1717
1818 const release = use ( ReleaseContext ) ;
19+
1920 const t = useTranslations ( ) ;
2021
22+ // Compute the platform during render so it's available to both `useEffect` calls below in the same cycle
23+ // (avoiding race conditions when architecture detection and OS detection arrive in the same batch)
24+ const currentPlatform =
25+ architecture && bitness ? getUserPlatform ( architecture , bitness ) : null ;
26+
2127 useEffect (
2228 ( ) => {
23- if ( architecture && bitness ) {
24- const autoDetectedPlatform = getUserPlatform ( architecture , bitness ) ;
25-
26- release . setPlatform ( autoDetectedPlatform ) ;
29+ if ( currentPlatform ) {
30+ release . setPlatform ( currentPlatform ) ;
2731 }
2832 } ,
2933 // Only react on the change of the Client Context Architecture and Bitness
@@ -49,12 +53,14 @@ const PlatformDropdown: FC = () => {
4953 useEffect (
5054 ( ) => {
5155 if ( release . os !== 'LOADING' && release . platform !== '' ) {
52- release . setPlatform ( nextItem ( release . platform , parsedPlatforms ) ) ;
56+ // Use the current platform if available, otherwise fall back to the current release platform
57+ const currentTargetPlatform = currentPlatform ?? release . platform ;
58+ release . setPlatform ( nextItem ( currentTargetPlatform , parsedPlatforms ) ) ;
5359 }
5460 } ,
5561 // We only want to react on the change of the OS and Version
5662 // eslint-disable-next-line @eslint-react/exhaustive-deps
57- [ release . os , release . version , release . platform ]
63+ [ release . os , release . version ]
5864 ) ;
5965
6066 return (
0 commit comments