Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const defaultValueBlacklist = ['null', 'undefined']
// Workaround for issue https://github.com/reactjs/react-docgen/issues/221
// If prop has defaultValue it can not be required
if (prop.defaultValue) {
if (prop.type || prop.flowType) {
const propName = prop.type ? prop.type.name : prop.flowType.type
if (defaultValueBlacklist.indexOf(prop.defaultValue.value) > -1) {
return <code>{showSpaces(unquote(prop.defaultValue.value))}</code>
} else if (propName === 'func' || propName === 'function') {
return
} else if (propName === 'shape' || propName === 'object') {
try {
// We eval source code to be able to format the defaultProp here. This
// can be considered safe, as it is the source code that is evaled,
// which is from a known source and safe by default
// eslint-disable-next-line no-eval
const object = eval(`(${prop.defaultValue.value})`)
return (
)
} catch (e) {
const values = getType( prop ).value.map( ( { value } ) => (
<code>{showSpaces(unquote(value))}</code>
) )
return (