From 5de72ffb97e9886b7b2136fe09e0740ae5080e9e Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 13 Jan 2019 11:44:57 -0500 Subject: [PATCH] Loading syntax-specific rendering module Still mocked out for testing --- src/components/App/index.js | 3 +-- src/components/Render/index.js | 6 +++--- src/syntax/js.js | 5 +++++ src/syntax/pcre.js | 5 +++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 src/syntax/js.js create mode 100644 src/syntax/pcre.js diff --git a/src/components/App/index.js b/src/components/App/index.js index de2459c..b131888 100644 --- a/src/components/App/index.js +++ b/src/components/App/index.js @@ -58,7 +58,7 @@ class App extends React.PureComponent { try { const Render = await import( /* webpackChunkName: "render-[index]" */ - 'components/Render' // TODO: Import syntax-specific render component + `syntax/${ syntax }` ); // HACK: Fake loading time @@ -115,7 +115,6 @@ class App extends React.PureComponent { }; const renderProps = { onRender: this.handleSvg, - syntax, expr }; diff --git a/src/components/Render/index.js b/src/components/Render/index.js index d531580..3785003 100644 --- a/src/components/Render/index.js +++ b/src/components/Render/index.js @@ -30,9 +30,10 @@ class Render extends React.PureComponent { } render() { - const { syntax, expr } = this.props; + const { expr } = this.props; - console.log('Render:', syntax, expr); // eslint-disable-line no-console + // eslint-disable-next-line no-console + console.log('Render:', this.constructor.name, expr); // Demo rendering for now return
@@ -42,7 +43,6 @@ class Render extends React.PureComponent { } Render.propTypes = { - syntax: PropTypes.string, expr: PropTypes.string, onRender: PropTypes.func.isRequired }; diff --git a/src/syntax/js.js b/src/syntax/js.js new file mode 100644 index 0000000..aefec9a --- /dev/null +++ b/src/syntax/js.js @@ -0,0 +1,5 @@ +import Render from 'components/Render'; + +class RenderJS extends Render {} + +export default RenderJS; diff --git a/src/syntax/pcre.js b/src/syntax/pcre.js new file mode 100644 index 0000000..11c32d9 --- /dev/null +++ b/src/syntax/pcre.js @@ -0,0 +1,5 @@ +import Render from 'components/Render'; + +class RenderPCRE extends Render {} + +export default RenderPCRE;