Skip to content
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

Addon-docs: Fix TS false default value in prop table #9560

Merged
merged 2 commits into from Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/cra-ts-kitchen-sink/src/stories/Button.tsx
Expand Up @@ -10,6 +10,11 @@ interface ButtonProps {
* Is primary?
*/
primary: boolean;

/**
* default is false
*/
secondary: boolean;
}

/**
Expand All @@ -23,4 +28,5 @@ export const Button: FC<ButtonProps> = ({ children, onClick }) => (

Button.defaultProps = {
primary: true,
secondary: false,
};
5 changes: 3 additions & 2 deletions lib/components/src/blocks/PropsTable/PropValue.tsx
Expand Up @@ -75,11 +75,12 @@ const PropSummary: FC<PropSummaryProps> = ({ value }) => {
const { summary, detail } = value;

const [isOpen, setIsOpen] = useState(false);

// summary is used for the default value
// below check fixes not displaying default values for boolean typescript vars
const summaryAsString =
summary && typeof summary.toString === 'function' ? summary.toString() : summary;
summary !== undefined && summary !== null && typeof summary.toString === 'function'
? summary.toString()
: summary;
if (isNil(detail)) {
return <PropText text={summaryAsString} />;
}
Expand Down