1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

@storybook/addon-docsでNo inputs found for this component.が表示された時の対応

Posted at

はじめに

@storybook/addon-docsを導入したところ、本来propsの項目が表示されるはずの箇所にNo inputs found for this component.が表示されてしまう状態でした。
解決してみれば大した原因ではなかったのですが、地味に時間がかかったので備忘録として残しておきます。同じ現象でハマっているひとの助けになれば幸いです。

参考画像

解決方法

storieファイルにインポートしたReactComponent名とファイル名に差異があるとpropsの項目が表示できないらしく、今回の現象が発生した環境では、tsxのファイル名をケバブケースで記載するルールにしており、ファイル名が小文字になっていたためコンポーネント名と差異が発生していました。

button.tsx
const Button:React.FC<Props> = (props) => {
  return (
    <StyledButton className={ props.className } to={props.to}>
      <ButtonText>{ props.children }</ButtonText>
    </StyledButton>
  );
}
export default Button;

ファイル名をButton.tsxに変更したところpropsの項目を意図した通りに表示することができました。
とりあえずファイル名はパスカルケースで記載するルールに変更。

補足

ハイフンが入る分には問題ないらしく、大文字小文字の差異が主な原因のようです。
例えば、IconBtnという名前のコンポーネントを持つicon-btn.tsxのようなファイルはIcon-Btn.tsxにすることでpropsの項目を表示できるようです

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?