Addon-docs: Hide React default props in source block #13003
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #11510
What I did
Added option to not show default props on code preview when a component isn't overriding those values. In
jsxDecorator.tsx
, it is using thereactElementToString
method from the react-element-to-jsx-string package. If you check their options, they accept ashowDefaultProps
property, which when set tofalse
omits the default props in the JSX. This sets that tofalse
so it doesn't show the default props by default.How to test
Yes. I added a test case, but it looks like it is failing due to a snapshot. I'm not familiar with snapshots, so I could use some help there please.
No
Yeah I think so, but I'm struggling determining where that would be added the best. Any advice?
If your answer is yes to any of these, please make sure to include it in your PR.