Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion typings/react-live.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentClass, StatelessComponent, HTMLProps, ComponentType } from 'react'
import { ComponentClass, StatelessComponent, HTMLProps, ComponentType, Context } from 'react'
import { PrismTheme, Language } from 'prism-react-renderer';

// Helper types
Expand Down Expand Up @@ -32,6 +32,17 @@ export type EditorProps = Omit<PreProps, 'onChange'> & {

export const Editor: ComponentClass<EditorProps>

// Context
export interface ContextProps {
code?: string;
language?: Language;
theme: PrismTheme;
disabled?: boolean;
error?: string;
}

export const LiveContext: Context<ContextProps>;

// LiveEditor
export type LiveEditorProps = EditorProps;

Expand Down
7 changes: 7 additions & 0 deletions typings/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
LiveEditor,
LiveError,
LivePreview,
LiveContext,
withLive
} from '../';
import * as React from 'react';
Expand Down Expand Up @@ -34,6 +35,12 @@ export const liveEditorC = <LiveEditor onChange={(code: string) => {}} />;

export const liveErrorC = <LiveError />;

export const customError = () => (
<LiveContext.Consumer>
{({ error }) => (error ? <pre>{error}</pre> : null)}
</LiveContext.Consumer>
);

export const livePreviewC = <LivePreview />;

const Component: React.StatelessComponent<{}> = () => <div>Hello World!</div>;
Expand Down