Improving Gatsby rendering solution

Now the form will be prerendered
This commit is contained in:
Jeff Avallone 2019-01-11 23:12:45 -05:00
parent 9a4f669c2d
commit 1f5da0c690
2 changed files with 10 additions and 1 deletions

View File

@ -146,7 +146,7 @@ class App extends React.PureComponent {
}; };
return <AppContext.Provider value={ context }> return <AppContext.Provider value={ context }>
{ syntax && <Form /> } <Form />
<Loader /> <Loader />

View File

@ -20,6 +20,15 @@ class Form extends React.PureComponent {
syntax: this.context.syntax 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 => { handleSubmit = event => {
event.preventDefault(); event.preventDefault();