Skip to content

Commit

Permalink
docs(Icon): more detailed migration guide (#3789)
Browse files Browse the repository at this point in the history
Refs #3771.
  • Loading branch information
asudoh authored Aug 26, 2019
1 parent 02edf93 commit 797ec5c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react/docs/migration/migrate-to-7.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for more information on migrating from v9 to v10.
| `FormGroup` | No breaking changes |
| `FormItem` | No breaking changes |
| `FormLabel` | No breaking changes |
| `Icon` | The `name` prop has been removed |
| `Icon` | [Migrate](../../src/components/Icon/migrate-to-7.x.md) |
| `InlineCheckbox` | [Migrate](../../src/components/InlineCheckbox/migrate-to-7.x.md) |
| `InlineLoading` | No breaking changes |
| `Link` | No breaking changes |
Expand Down
22 changes: 22 additions & 0 deletions packages/react/src/components/Icon/migrate-to-7.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Props

`<Icon>`

| Prop | v9 | v10 |
| ------ | ----------------------- | ------------------- |
| `name` | Points to the icon name | Removed (See below) |

## Notes for `v10`

The `<Icon>` component uses the `carbon-icons` library, which hosts a set of icons built for v9 of the Carbon Design System. In v10, we introduced `@carbon/icons-react` which offers an updated set of icons built for consumption as React components. However, we will still support both `carbon-icons` and `@carbon/icons-react` through v11.

While you can still use the `<Icon>` component, the `name` prop has been removed in `v10`. We removed the `name` prop in preference of the `icon` prop which will allow you to tree-shake icons in your build. You can use the `icon` prop by directly importing icons from `carbon-icons` and supplying them as the `icon` prop. For example:

```js
import { Icons } from 'carbon-components-react';
import { iconAdd } from 'carbon-icons';

<Icon icon={iconAdd} />
```

This `icon` prop is a data structure that we use to represent an icon in code. You can pass in your own icons if they follow this data structure. For more information, you can view the [`icon` prop type](https://github.com/carbon-design-system/carbon/blob/v10.3.0/packages/react/src/components/Icon/Icon.js#L189-L194) in addition to the exports from [`carbon-icons`](https://unpkg.com/browse/[email protected]/dist/carbon-icons-list.js).

0 comments on commit 797ec5c

Please sign in to comment.