How to use the react-live.withLive function in react-live

To help you get started, we’ve selected a few react-live 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 grommet / grommet-site / src / components / playground / PlaygroundError.js View on Github external
import React from 'react';
import { withLive } from 'react-live';

import { Box, Text } from 'grommet';

const PlaygroundError = withLive(({ error }) => {
  if (!error) {
    return null;
  }
  return (
    
      
    
  );
});

export { PlaygroundError };
github looker-open-source / components / packages / www / src / MDX / Pre / CodeSandbox.tsx View on Github external
language: string
  theme: PrismTheme
  onChange: () => void
  onError: () => void
}

interface WithLiveProps {
  children: (error?: string) => ReactNode
  live?: LiveProps
}

const LivePreviewWrapper = styled.div`
  position: relative;
`

export const LiveConsumer = withLive(({ children, live }) => {
  return <>{children((live as LiveProps).error)}
})

interface ActionProps {
  editorIsVisible: boolean
}

interface CopyButtonProps extends ActionProps {
  code: string
}

export const CopyButton: FC = ({ code, editorIsVisible }) => {
  return (
    
      {(eventHandlers, ref) => (
github patternfly / patternfly-react / packages / patternfly-4 / react-docs / src / components / example / liveDemo.js View on Github external
)}
          
          {codeOpen && }
          {live && }
        
      
    );
  }
}

LiveDemo.propTypes = propTypes;
LiveDemo.defaultProps = defaultProps;

export default withLive(LiveDemo);
github grommet / grommet-site / src / components / playground / PlaygroundPlaceholder.js View on Github external
import React from 'react';
import { withLive } from 'react-live';

import { Box, Heading } from 'grommet';
import { Gremlin } from '../Gremlin';

const PlaygroundPlaceholder = withLive(({ error }) => {
  if (!error) {
    return null;
  }
  return (
    
      Oh, no!
      
        Something went wrong, check your code...
github styled-components / styled-components-website / pages / index.js View on Github external
\`
`).trim()

import {
  BloombergLogo,
  AtlassianLogo,
  RedditLogo,
  TargetLogo,
  EuroVisionLogo,
  ArtsyLogo,
  IdeaLogo,
  HuffpostLogo,
  CoinbaseLogo,
} from '../components/CompanyLogos'

const HomepageLivePreview = withLive(({
  live: { element: Button = FallbackButton },
  className,
  ...rest
}) => {
  const LiveButton = Button.extend.withConfig({ componentId: 'LiveButton' })``
  const LiveInternalButton = Button.withComponent(Link).extend.withConfig({ componentId: 'LiveInternalButton' })``

  return (
    <div>
      </div>
github react-bootstrap / react-bootstrap / www / src / components / ReactPlayground.js View on Github external
);
  }
}

const prettierComment = /(\{\s*\/\*\s+prettier-ignore\s+\*\/\s*\})|(\/\/\s+prettier-ignore)/gim;

const { background, foreground } = css`
  @import '../css/theme';

  :export {
    background: $lighter;
    foreground: $subtleOnDark;
  }
`;

const Preview = withLive(
  class extends React.Component {
    constructor() {
      super();

      this.example = null;
    }

    componentDidMount() {
      import('holderjs').then(({ default: hjs }) => {
        this.hjs = hjs;
        hjs.addTheme('gray', {
          bg: background,
          fg: foreground,
          font: 'Helvetica',
          fontweight: 'normal',
        });

react-live

A production-focused playground for live editing React code

MIT
Latest version published 1 month ago

Package Health Score

92 / 100
Full package analysis