Codemods

The American Express Design System provides a unified language for designing American Express websites and experiences. The design system provides design resources that match our coded components and are aligned with the American Express brand. Included are colors, components, icons and glyphs, type styles, and graphic assets to get you up and running quickly.

Back to All Codemods

RadioGroup Transform

Converts the v6 RadioGroup component to the v7 RadioGroup component.

Automatic Changes

  • Renames the checked prop to value
  • Renames defaultChecked prop to defaultValue.
  • Migrates the contents of the Legend subcomponent into the legend prop of the RadioGroup, if it exists.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.

For example:

import { RadioGroup } from '@americanexpress/dls-react6';

export default function Page() {

return (

<RadioGroup

checked={currentValue}

defaultChecked={defaultValue}

theme={{ color: 'red' }}

{...otherProps}

>

<Legend>Some Legend</Legend>

{/** Other Children */}

</RadioGroup>

);

}

Transforms into:

import { RadioGroup } from '@americanexpress/dls-react';

export default function Page() {

return (

<RadioGroup

value={currentValue}

defaultValue={defaultValue}

legend={<>Some Legend</>}

{...otherProps}

>

{/** Other Children */}

</RadioGroup>

);

}

Manual Changes

Legend

There are new props for handling the legend associated with a group of radio buttons. Move the text contents of the associated Legend component to the legend prop of the RadioGroup component. If the legend should be hidden, set the isLegendHidden prop to true.

onChange API Update

Previously, the onChange callback provided a second parameter in the callback which provided event.target.value. If your application was previously relying on this second parameter, switch to directly referencing event.target.value:

Switch from this:

<RadioGroup onChange={(event, value) => setValue(value)} />

To this:

<RadioGroup onChange={(event) => setValue(event.target.value)} />

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.