From 1f5da0c69005ed9d25c3ab4e2099e99417619b48 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Fri, 11 Jan 2019 23:12:45 -0500 Subject: [PATCH] Improving Gatsby rendering solution Now the form will be prerendered --- src/components/App/index.js | 2 +- src/components/Form/index.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/App/index.js b/src/components/App/index.js index 9b4109d..009c171 100644 --- a/src/components/App/index.js +++ b/src/components/App/index.js @@ -146,7 +146,7 @@ class App extends React.PureComponent { }; return - { syntax &&
} + diff --git a/src/components/Form/index.js b/src/components/Form/index.js index e7dc39e..bf8167a 100644 --- a/src/components/Form/index.js +++ b/src/components/Form/index.js @@ -20,6 +20,15 @@ class Form extends React.PureComponent { syntax: this.context.syntax } + componentDidUpdate() { + if (this.state.expr === undefined && this.state.syntax === undefined) { + this.setState({ + syntax: this.context.syntax, + expr: this.context.expr + }); + } + } + handleSubmit = event => { event.preventDefault();