Skip to content

Commit

Permalink
autogenerate id
Browse files Browse the repository at this point in the history
  • Loading branch information
agneym committed Nov 20, 2019
1 parent c5c1bc6 commit f54926d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
29 changes: 21 additions & 8 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { Fragment } from "react";
import { render } from "react-dom";
import "babel-polyfill";
import Playground from "@agney/playground";
Expand All @@ -18,13 +18,26 @@ render(app, document.getElementById('app'));
`,
};
return (
<Playground
id="example"
initialSnippet={snippet}
defaultEditorTab="javascript"
transformJs
presets={["react"]}
/>
<Fragment>
<Playground
initialSnippet={snippet}
defaultEditorTab="javascript"
transformJs
presets={["react"]}
/>
<Playground
initialSnippet={snippet}
defaultEditorTab="javascript"
transformJs
presets={["react"]}
/>
<Playground
initialSnippet={snippet}
defaultEditorTab="javascript"
transformJs
presets={["react"]}
/>
</Fragment>
);
};

Expand Down
16 changes: 9 additions & 7 deletions playground/src/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ const Playground: FC<IProps> = ({
defaultTab={defaultEditorTab}
onChange={onSnippetChange}
/>
<Result
id={id}
snippet={snippet}
defaultTab={defaultResultTab}
transformJs={transformJs}
presets={presets}
/>
{id && (
<Result
id={id}
snippet={snippet}
defaultTab={defaultResultTab}
transformJs={transformJs}
presets={presets}
/>
)}
</Container>
</ThemeProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion playground/src/Result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Result: FC<IProps> = ({
data.data.source === `frame-${id}` &&
data.data.message.type === "log"
) {
setLogs(prevLogs => [...prevLogs, ...data.data.message]);
setLogs(prevLogs => [...prevLogs, ...data.data.message.data]);
}
});
}
Expand Down

0 comments on commit f54926d

Please sign in to comment.