Skip to content

Commit

Permalink
fix(docz-theme-default): using lodash.get to prevent classname crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 6, 2018
1 parent 0dbd8f0 commit befc643
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/docz-theme-default/src/components/ui/Pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BaseCheck from 'react-feather/dist/icons/check'
import SyntaxHighlighter from 'react-syntax-highlighter/prism-light'
import Clipboard from 'react-feather/dist/icons/clipboard'
import copy from 'copy-text-to-clipboard'
import get from 'lodash.get'

import { ButtonSwap } from './ButtonSwap'
import { ButtonLink } from './Button'
Expand All @@ -24,15 +25,13 @@ const PrismTheme = styled('pre')`
flex: 1;
`

const getChildren = (children: any) => {
return children && typeof children !== 'string'
? children.props.children
: children
}
const getChildren = (children: any) =>
children && typeof children !== 'string' ? children.props.children : children

const getLanguage = (children: any) => {
if (typeof children === 'string') return 'language-jsx'
return children.props.props.className
const defaultLanguage = 'language-jsx'
if (typeof children === 'string') return defaultLanguage
return get(children, 'props.props.className') || defaultLanguage
}

const getCode = (content: any): SFC => ({ children }) => {
Expand Down

0 comments on commit befc643

Please sign in to comment.