- If the codemod leaves
TODO(S2-upgrade)next to an icon or illustration import, pick the nearest S2 replacement manually.
Flex, Grid, View, and Well are not part of S2. These should be updated to div elements styled with the macro.
Before:
<Flex direction="column">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</Flex>After:
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
<div className={style({display: 'flex', flexDirection: 'column'})}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>Before:
<Grid justifyContent="center">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</Grid>After:
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
<div className={style({display: 'grid', justifyContent: 'center'})}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>Before:
<View>
Content
</View>After:
<div>
Content
</div>Before:
<Well>
Content
</Well>After:
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
<div className={style({
display: 'block',
textAlign: 'start',
padding: 16,
minWidth: 160,
marginTop: 4,
borderWidth: 1,
borderRadius: 'sm',
borderStyle: 'solid',
borderColor: 'transparent-black-75',
font: 'body-sm'
})}>
Content
</div>Move UNSAFE_style usage to the S2 style macro when possible.
Move UNSAFE_className usage to the S2 style macro when possible.
Reference the S2 styling docs to see the supported CSS properties.
DialogContaineranduseDialogContainerstill exist in S2, but the dismiss logic may need to move betweenDialog,DialogTrigger, andDialogContainer. See the S2 Dialog documentation for more details.
-
When
Itemsurvives the codemod, rename it based on its parent component:Parent component v3 child S2 child Menu / ActionMenu Item MenuItem Picker Item PickerItem ComboBox Item ComboBoxItem Tabs Item Tab / TabPanel TagGroup Item Tag Breadcrumbs Item Breadcrumb -
Preserve React
keywhen mapping arrays, but ensure collection data items exposeidwhen S2 expects it. See the S2 Collections documentation for more details. -
Table and ListView migrations often need manual review for row headers, nested columns, and explicit item ids.
- Move
ToastContainerandToastQueueimports from@react-spectrum/toastto@react-spectrum/s2. - Keep a shared
ToastContainermounted near the app root or test harness, then update all queue calls to use the S2 import path. - S2 supports
ToastQueue.neutral,positive,negative, andinfo. - Re-check options such as
timeout,actionLabel,onAction,shouldCloseOnAction, andonCloseafter the import move. - The queue methods still return a close function. Keep programmatic dismissal logic when the existing UX depends on it.
- Search for every
ToastContainermount and everyToastQueueusage after moving imports. Shared app roots, secondary entrypoints, and test harnesses are easy to miss.