Prop table broken in 5.3.2 with propTypes
See original GitHub issueDescribe the bug
On upgrading to 5.3.2, any props defined with propTypes
are not building the prop table
To Reproduce Declare propTypes for a component. Open storybook and see that it hasn’t generated a prop table.
Expected behavior Expected to see prop information
Screenshots
Before
After upgrading
Code snippets
class Dropdown extends React.Component {
constructor() {
super()
this.state = { show_action_sheet: false }
this.toggleActionSheet = this.toggleActionSheet.bind(this)
}
toggleActionSheet() {
this.setState({ show_action_sheet: !this.state.show_action_sheet })
}
render() {
const {
split,
} = this.props
const isMobile = detectMobile()
let DropdownComponent
if (split) {
DropdownComponent = isMobile ? SplitDropdownActionSheet : SplitDropdownRegular
} else {
DropdownComponent = isMobile ? DropdownActionSheet : DropdownRegular
}
return (
<DropdownComponent {...this.props}
show_action_sheet={this.state.show_action_sheet}
toggleActionSheet={this.toggleActionSheet}
/>
)
}
}
Dropdown.propTypes = {
split: PropTypes.bool, // pass true for a split button. If true, must pass either href or onClick
href: PropTypes.string, // href for split button
onClick: PropTypes.func, // onClick handler for split button
noCaret: PropTypes.bool, // pass true to not show a caret
action_sheet_title: PropTypes.oneOfType([ // pass this to show a title displayed for context on action sheet
PropTypes.string,
PropTypes.element,
]),
className: PropTypes.string,
jane_only: PropTypes.bool,
pullRight: PropTypes.bool,
disabled: PropTypes.bool,
options: PropTypes.arrayOf(PropTypes.object).isRequired, // [{}, {}]
bsSize: PropTypes.oneOf(
['large', 'lg', 'small', 'sm', 'xsmall', 'xs']
),
bsStyle: PropTypes.oneOf(
["success", "warning", "danger", "info", "default", "primary", "link"]
),
}
System:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.12.1 - ~/.nvm/versions/node/v8.11.3/bin/npm
Browsers:
Chrome: 79.0.3945.117
Safari: 13.0.4
npmPackages:
@storybook/addon-actions: ^5.3.2 => 5.2.5
@storybook/addon-docs: ^5.3.2 => 5.2.5
@storybook/addon-knobs: ^5.3.2 => 5.2.5
@storybook/addon-links: ^5.3.2 => 5.2.5
@storybook/addons: ^5.3.2 => 5.2.5
@storybook/react: ^5.3.2 => 5.2.5
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:38 (16 by maintainers)
Top Results From Across the Web
React eslint error missing in props validation - Stack Overflow
You need to define propTypes as a static getter if you want it inside the class declaration: static get propTypes() { return {...
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Open Source Notices - Itential Documentation
... acorn-jsx@5.3.2,npm,MIT acorn-walk@6.2.0,npm,MIT acorn-walk@8.2.0,npm,MIT ... babel-plugin-transform-react-remove-prop-types@0.4.24,npm,MIT ...
Read more >Mastering Props And PropTypes In React - Smashing Magazine
In this snippet, we are passing a prop named posts to a component named PostList . This prop has a value of {postsList}...
Read more >https://community.dhis2.org/uploads/short-url/lMmW...
resolution: "@babel/helper-split-export-declaration@npm:7.16.7" ... resolution: "@babel/plugin-syntax-class-properties@npm:7.12.13" ... version: 5.3.2.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the helpful explanation @shilman, it explained why it was working before and I realized that we actually hadn’t previously added that as a dependency as it had worked without it.
@danilovaz I fixed by adding
babel-plugin-react-docgen
as a dev dependency, and then addingreact-docgen
to plugins for thebabel-loader
in my webpack config (as our project doesn’t use a .babelrc).Its’a an option @shilman , I dont like it though.
It shouldn’t have ever work without the proper babel plugin setup and it’s an easy fix for the user.
If we had back the fallback, I fear we might end up with weird issues that might take a lot of our time to figure out what’s happening.
Could we instead update the error message to suggest to configure properly the babel plugin required by the props table?