From 86f67a9b57dcc0e0cdcb80f0dcfebc94699fa402 Mon Sep 17 00:00:00 2001 From: atanasster Date: Mon, 20 Jan 2020 10:16:23 -0500 Subject: [PATCH] bolean props default false --- examples/cra-ts-kitchen-sink/src/stories/Button.tsx | 6 ++++++ lib/components/src/blocks/PropsTable/PropValue.tsx | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/cra-ts-kitchen-sink/src/stories/Button.tsx b/examples/cra-ts-kitchen-sink/src/stories/Button.tsx index 7f0292d659cd..fbfac0b1c52d 100644 --- a/examples/cra-ts-kitchen-sink/src/stories/Button.tsx +++ b/examples/cra-ts-kitchen-sink/src/stories/Button.tsx @@ -10,6 +10,11 @@ interface ButtonProps { * Is primary? */ primary: boolean; + + /** + * default is false + */ + secondary: boolean; } /** @@ -23,4 +28,5 @@ export const Button: FC = ({ children, onClick }) => ( Button.defaultProps = { primary: true, + secondary: false, }; diff --git a/lib/components/src/blocks/PropsTable/PropValue.tsx b/lib/components/src/blocks/PropsTable/PropValue.tsx index 1c7ac698c09a..f40d22996497 100644 --- a/lib/components/src/blocks/PropsTable/PropValue.tsx +++ b/lib/components/src/blocks/PropsTable/PropValue.tsx @@ -75,11 +75,12 @@ const PropSummary: FC = ({ 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 ; }