Addon-docs: Fix props table props sorting for PropTypes #8857
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: #8539
What I did
The sorting problems comes from react-docgen that mess up the original sorting order of the props by returning first the props that have a default value.
My fix consist of using the original definition of the PropTypes object to re-order the props based on their original definition order.
This only fix the problem for PropTypes. If other frameworks or type systems have the same problem, they will also need to be fixed.
How to test
Jest:
yarn jest --testPathPattern=handleProp
cra-ts-kitchen-sink: ?path=/docs/propssort--page
If your answer is yes to any of these, please make sure to include it in your PR.