-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fixed prop type validation errors in info addon #1374
Conversation
Update from origin
…elements for arrays and objects.
Codecov Report
@@ Coverage Diff @@
## release/3.3 #1374 +/- ##
===============================================
- Coverage 23.47% 21.75% -1.73%
===============================================
Files 311 355 +44
Lines 6538 7069 +531
Branches 827 914 +87
===============================================
+ Hits 1535 1538 +3
- Misses 4399 4842 +443
- Partials 604 689 +85
Continue to review full report at Codecov.
|
Making eslint happy makes codebeat unhappy. |
Makes me unhappy :'(.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to completely change our approach for source generation. |
This seems like a good bug fix that we should be merging into master? Doesn't seem like our Info refactor is gonna happen for 3.3. edit: just kidding, I hate how we do our branch merges. It makes switching branches almost impossible. Let's get this into 3.3. |
@@ -51,13 +52,19 @@ function previewArray(val, maxPropArrayLength) { | |||
return <span style={valueStyles.array}>[{createFragment(items)}]</span>; | |||
} | |||
|
|||
function previewObject(val, maxPropObjectKeys) { | |||
previewArray.propTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previewArray
is never rendered as a component, it's only called as a function. So looks like those propTypes aren't really checked at any point. You should either remove them, or capitalize the name (PreviewArray
) and replace previewArray(props)
below with <PreviewArray {...props} />
.
If you decide to do the latter, please note that val
should rather be PropTypes.array
, and don't disable all of the eslint rules — only the particular ones (// eslint-disable react/forbid-prop-types
)
Codecov Report
@@ Coverage Diff @@
## release/3.3 #1374 +/- ##
===============================================
+ Coverage 22.74% 23.51% +0.76%
===============================================
Files 326 311 -15
Lines 6750 6546 -204
Branches 847 824 -23
===============================================
+ Hits 1535 1539 +4
+ Misses 4603 4409 -194
+ Partials 612 598 -14
Continue to review full report at Codecov.
|
Gonna close this PR due to inactivity. Feel free to ping us if you'd like to keep working on it. |
Issue: #1305
What I did
Updated PropVal.js to pass its props to child elements in case of arrays and objects.
How to test
Render a story using
addWithInfo
with a component that receives an array or an object as a prop. Open console to verify you no longer receive errors due to properties validation for PropVal component.