-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
<!--- PROPS --> not caught with styled-components HOC #131
Comments
exported component should be with defined
This should work: import React from 'react';
import PropTypes from 'prop-types';
import styled, { withTheme } from 'styled-components';
const Button = styled.button`
`;
Button.propTypes = {
label: PropTypes.string.isRequired,
onClick: PropTypes.func,
variant: PropTypes.oneOf(['success', 'warning', 'alert']),
};
export default withTheme(Button); This also will work: import React from 'react';
import PropTypes from 'prop-types';
import styled, { withTheme } from 'styled-components';
const Button = styled.button`
`;
const ButtonWithTheme = withTheme(Button);
ButtonWithTheme.propTypes = {
label: PropTypes.string.isRequired,
onClick: PropTypes.func,
variant: PropTypes.oneOf(['success', 'warning', 'alert']),
};
export default ButtonWithTheme; This will NOT work: import React from 'react';
import PropTypes from 'prop-types';
import styled, { withTheme } from 'styled-components';
const Button = styled.button`
`;
Button.propTypes = {
label: PropTypes.string.isRequired,
onClick: PropTypes.func,
variant: PropTypes.oneOf(['success', 'warning', 'alert']),
};
export default props => <Button {...props} />; |
Actually I’m doing the first one and it doesn’t work mate. |
I made some local tests and everything is ok with What version of |
I’m out home but I guess it’s yours version. Latest stable. The only difference I remember(later I’ll check it better), is I’m using default props too but damn it the code is almost the same. (All speaking from memory) |
released example https://tuchk4.github.io/storybook-readme/?path=/story/propstable--button with Please try |
Valerii have you tried my proposal? |
Sorry for long reply. See error now. I would like to link this issue with #137 because of errors around the same problem. |
Hi!!
I'm using on some components withTheme() HOC from styled-components, actually this addon can't get the props table working with it.
Thanks!
The text was updated successfully, but these errors were encountered: