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] stateless component No propTypes defined! on prop table in build mode #1141

Closed
Stupidism opened this issue May 28, 2017 · 8 comments

Comments

@Stupidism
Copy link
Contributor

I have a simple stateless component:

const Counter = ({ count }) => (
  <div style={styles.counter}>{count}</div>
);

Counter.propTypes = {
  count: T.number.isRequired,
};

Expected

It renders normally in dev mode, when I call start-storybook -p 6006
image

Current

Props are missing in build mode, when I call build-storybook -o gh-pages
online demo is here

@Stupidism Stupidism changed the title props missing in build mode [addon-info] stateless component props missing on prop table in build mode May 28, 2017
@Stupidism Stupidism changed the title [addon-info] stateless component props missing on prop table in build mode [addon-info] stateless component No propTypes defined! on prop table in build mode May 28, 2017
@shilman
Copy link
Member

shilman commented May 28, 2017

@Stupidism what happens when you run the build with NODE_ENV=development?

@Stupidism
Copy link
Contributor Author

Stupidism commented May 28, 2017

@shilman It's working with NODE_ENV=development build-storybook -o gh-pages

@shilman
Copy link
Member

shilman commented May 29, 2017

Seems like something is stripping out the proptypes when the production flag is set. Perhaps a webpack plugin? Haven't had time to dig in, but it seems like something that should be easy to diagnose and fix.

@Stupidism
Copy link
Contributor Author

Stupidism commented May 29, 2017

@shilman Things are getting even worse.
image

I already fixed it temporarily in my repo. If you want to reproduce it. Just run

git clone git@github.com:Stupidism/stupid-rc-starter.git
cd stupid-rc-starter && yarn install
./node_modules/.bin/build-storybook -o gh-pages && npm run gh-pages:opn

You will see the bug in your_local_url/?selectedKind=RenderCounter&selectedStory=Counter

@Stupidism
Copy link
Contributor Author

Is there any progress on this?

@danielduan
Copy link
Member

Related to #1661, fixing the docgen part here: #1725.

Will require a separate PR to set NODE_ENV in Webpack for prop-types for components that can't be documented using docgen.

@Stupidism
Copy link
Contributor Author

It seems to be fixed now.

@feonit
Copy link

feonit commented Jan 15, 2019

It still not worked for me. Here my component:

import React from "react";
import "./Background.css";
import PropTypes from "prop-types";

const Background = (props) => {
	const {children} = props;
	return (
		<div className={"Background"}>
			{children}
		</div>
	)
};

Background.displayName = "Background";

Background.propTypes = {
	/** My content */
	children: PropTypes.any.isRequired
};
export default Background;

For command NODE_ENV=production npm run storybook i have:
2019-01-15 18 33 02

And for npm run storybook:
2019-01-15 18 37 47

Same for the rest of the components too. But when i added:

Background.defaultProps = {
	children: 'my text'
};

the following happens:
2019-01-15 18 43 25

I use:

    "@storybook/addon-info": "4.1.2",
    "@storybook/addon-knobs": "4.1.2",
    "@storybook/addon-options": "4.1.2",
    "@storybook/cli": "4.1.2",
    "@storybook/react": "4.1.2",

is amazing

Am I doing something wrong?

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

5 participants