How to use the react-styleguidist/lib/rsg-components/Props/util.unquote function in react-styleguidist

To help you get started, we’ve selected a few react-styleguidist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amalto / platform6-ui-components / typescript / custom / PropsRenderer.tsx View on Github external
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) {
github amalto / platform6-ui-components / typescript / custom / PropsRenderer.tsx View on Github external
const values = getType( prop ).value.map( ( { value } ) =&gt; (
            <code>{showSpaces(unquote(value))}</code>
        ) )
        return (