Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Default export doesn't work when no named exports are present #75

Open
ElForastero opened this issue Nov 29, 2019 · 0 comments
Open

Default export doesn't work when no named exports are present #75

ElForastero opened this issue Nov 29, 2019 · 0 comments

Comments

@ElForastero
Copy link

ElForastero commented Nov 29, 2019

The source of the issue in this comment in storybook repo.

I have repeated the steps from Storybook Docs Typescript Walkthrough.

Everything works fine, except for default exports.
If there are no named exports, default exports don't work.

Story

import React from 'react';
import Button from './Test';

export default {
  title: 'base/Button',
  component: Button,
};

export const primary = () => <Button>Push me</Button>;

Component.

This one doesn't work.

import React, { FC } from "react";

interface ButtonProps {
  /**
   * Simple click handler
   */
  onClick?: () => void;
}

/**
 * The world's most _basic_ button
 */
const Button: FC<ButtonProps> = ({ children, onClick }) => (
  <button onClick={onClick} type="button">
    {children}
  </button>
);

export default Button;

But this works fine

Note an export statement near the Button.

import React, { FC } from "react";

interface ButtonProps {
  /**
   * Simple click handler
   */
  onClick?: () => void;
}

/**
 * The world's most _basic_ button
 */
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
  <button onClick={onClick} type="button">
    {children}
  </button>
);

export default Button;

Screenshots:

No named export

image

With named export

image

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

No branches or pull requests

1 participant