Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addon: info - v5.x] No Prop Types table if using React.forwardRef #6345

Closed
liamross opened this issue Mar 29, 2019 · 9 comments
Closed

[Addon: info - v5.x] No Prop Types table if using React.forwardRef #6345

liamross opened this issue Mar 29, 2019 · 9 comments

Comments

@liamross
Copy link

liamross commented Mar 29, 2019

Describe the bug

In version 5.0.x of the info addon, the Prop Types section is not appearing if the component is wrapped in forwardRef. This is in a TypeScript project.

Screen Shot 2019-03-29 at 11 13 02 AM

Note: may be related to #5974

To Reproduce

  1. Create any component using forwardRef in React.

Expected behaviour

Should match up with the result of version 4.x (table is present)

System

  • OS: MacOS
  • Device: Macbook Pro 2018
  • Browser: all
  • Framework: React
  • Addons: info
  • Version: 5.0.g
  • Language: TypeScript
@liamross
Copy link
Author

Maybe related to #3389 as well? Regression?

@shilman
Copy link
Member

shilman commented Apr 9, 2019

How did you setup docgen for typescript?

@shilman shilman added this to the 5.0.x milestone Apr 9, 2019
@liamross
Copy link
Author

liamross commented Apr 10, 2019

@shilman

.storybook/webpack.config.js
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = ({ config: defaultConfig }) => {
  // Extend defaultConfig as you need.

  // Sass loader:
  defaultConfig.module.rules.push({
    test: /\.scss$/,
    loaders: ['style-loader', 'css-loader', 'sass-loader'],
    include: [path.resolve(__dirname, '../src'), path.resolve(__dirname)],
  });
  defaultConfig.resolve.extensions.push('.scss');

  // Typescript loader:
  defaultConfig.module.rules.push({
    test: /\.(ts|tsx)$/,
    use: [
      { loader: require.resolve('ts-loader') },
      { loader: require.resolve('react-docgen-typescript-loader') },
    ],
  });
  defaultConfig.resolve.extensions.push('.ts', '.tsx');

  // Resolve baseUrl:
  if (!defaultConfig.resolve.plugins) defaultConfig.resolve.plugins = [];
  defaultConfig.resolve.plugins.push(
    new TsconfigPathsPlugin({
      configFile: './tsconfig.json',
      baseUrl: 'src',
    }),
  );

  return defaultConfig;
};
Example of component with no Prop Table
import React, { forwardRef } from 'react';

export interface TestButtonProps {
  /**
   * Some input prop.
   * @default: "Default value"
   */
  someProp?: string;
  /**
   * Some onClick handler prop.
   */
  onClick?: () => void;
}

export const TestButton = forwardRef<HTMLButtonElement, TestButtonProps>(
  ({ someProp = 'Default value', onClick }, ref) => {
    return (
      <button onClick={onClick} ref={ref}>{someProp}</button>
    );
  },
);

And then addDecorator(withInfo); in .storybook/config.ts as the very first addDecorator

Does storybook 5.0 require a different set up? I know that the react-docgen-typescript-loader README still only shows examples for 4.x

@shilman
Copy link
Member

shilman commented Apr 11, 2019

@liamross No, there may have been some regressions in 5.0 but no material changes in addon-info specifically AFAIK. We'll be replacing it with a superior alternative very soon, so I'll be looking at this case as I work on that (and will patch addon-info if it's easy while I'm at it)

@stale
Copy link

stale bot commented May 2, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 2, 2019
@shilman shilman removed the inactive label May 2, 2019
@stale
Copy link

stale bot commented May 23, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 23, 2019
@shilman shilman modified the milestones: 5.0.x, 5.1.x Jun 5, 2019
@stale stale bot removed the inactive label Jun 5, 2019
@stale
Copy link

stale bot commented Jun 26, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jun 26, 2019
@shilman
Copy link
Member

shilman commented Jun 27, 2019

Addon-docs is in alpha now and is intended to replace addon-info. Please give it a try and see whether it solves this issue: https://docs.google.com/document/d/1un6YX7xDKEKl5-MVb-egnOYN8dynb5Hf7mq0hipk8JE/edit?usp=sharing

@stale stale bot removed the inactive label Jun 27, 2019
@liamross
Copy link
Author

It seems to have resolved itself actually!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants