How to use the react-view.formatCode function in react-view

To help you get started, we’ve selected a few react-view 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 uber / baseweb / documentation-site / components / yard / override.tsx View on Github external
onClick={() => {
            set({
              ...overrides.value,
              [overrideKey]: {
                style: formatCode(overrides.value[overrideKey].style),
                active: true,
              },
            });
          }}
        >
github uber / baseweb / documentation-site / components / yard / override.tsx View on Github external
onClick={() => {
            const newCode = formatCode(
              toggleOverrideSharedProps(
                overrides.value[overrideKey].style,
                Object.keys(overrides.custom.sharedProps),
              ),
            );
            set({
              ...overrides.value,
              [overrideKey]: {
                style: newCode,
                active: true,
              },
            });
          }}
        >
github uber / baseweb / documentation-site / components / yard / type-definition.js View on Github external
let errored = false;

  try {
    if (props.type.component.value.name === '$Shape') {
      value = props.type.component.typeParams.params[0];
      name = value.value.referenceIdName;
    } else {
      value = props.type.component.value;
      name = value.referenceIdName;
    }

    const proptypes = getPropTypes(value).map(property => {
      return convert(property, true);
    });

    definition = formatCode(`type ${name} = {` + proptypes.join(',') + '}');
  } catch (e) {
    errored = true;
  }

  if (errored) {
    return (
      <div>
        <p>
          extract-react-types is not being run in dev mode for speed reasons. If
          you need to see prop types, run:
        </p></div>