Skip to content

Commit

Permalink
Improve migration for react-typescript-docgen-loader to babel-plugin-…
Browse files Browse the repository at this point in the history
…react-docgen
  • Loading branch information
shilman committed Mar 6, 2020
1 parent a428974 commit 5f44c31
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
24 changes: 23 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,29 @@ In earlier versions, we recommended `react-docgen-typescript-loader` (`RDTL`) an

As a consequence we've removed `RDTL` from the presets, which is a breaking change. We made this change because `react-docgen` now supports TypeScript natively, and fewer dependencies simplifies things for everybody.

We will be updating this section with migration information as we collect information from our users.In the meantime, if you need to manually configure your setup to add back `react-docgen-typescript-loader`, add the following to your `.storybook/main.js`:
We will be updating this section with migration information as we collect information from our users, and fixing issues as they come up throughout the 6.0 prerelease process. We are cataloging known issues [here](https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#known-limitations).

The biggest known issue is https://github.com/reactjs/react-docgen/issues/387, which means that the following common pattern **DOESN'T WORK**:

```tsx
import React, { FC } from 'react';
interface IProps { ... };
const MyComponent: FC<IProps> = ({ ... }) => ...
```

The following workaround is needed:

```tsx
const MyComponent: FC<IProps> = ({ ... }: IProps) => ...
```

Please upvote https://github.com/reactjs/react-docgen/issues/387 if this is affecting your productivity, or better yet, submit a fix!

In the meantime, if you're not ready to make the move you have two options:

1. Pin your to a specific preset version: `preset-create-react-app@1.5.2` or `preset-typescript@1.2.2`

2. OR: Manually configure your setup to add back `react-docgen-typescript-loader`, add the following to your `.storybook/main.js`:

```js
module.exports = {
Expand Down
19 changes: 19 additions & 0 deletions addons/docs/docs/props-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Storybook Docs automatically generates props tables for components in supported
- [Reporting a bug](#reporting-a-bug)
- [Known limitations](#known-limitations)
- [React](#react)
- [Fully support React.FC](#fully-support-reactfc)
- [Vue](#vue)
- [Angular](#angular)
- [Web components](#web-components)
Expand Down Expand Up @@ -73,6 +74,24 @@ This package relies on a variety of sub-packages to extract property information

SB Docs for React uses `babel-plugin-react-docgen`/`react-docgen` for both JS PropTypes prop tables and, as of 6.0, TypeScript-driven props tables.

#### Fully support React.FC

The biggest known issue is https://github.com/reactjs/react-docgen/issues/387, which means that the following common pattern **DOESN'T WORK**:

```tsx
import React, { FC } from 'react';
interface IProps { ... };
const MyComponent: FC<IProps> = ({ ... }) => ...
```

The following workaround is needed:

```tsx
const MyComponent: FC<IProps> = ({ ... }: IProps) => ...
```

Please upvote https://github.com/reactjs/react-docgen/issues/387 if this is affecting your productivity, or better yet, submit a fix!

### Vue

SB Docs for Vue uses `vue-docgen-loader`/`vue-docgen-api` for SFC and JSX components.
Expand Down

0 comments on commit 5f44c31

Please sign in to comment.