ReadWithAudrey / readwithaudrey

Read books together with like-minded people who share your interests
3 stars 0 forks source link

Data Management in Gatsby #125

Closed matthall8 closed 6 years ago

matthall8 commented 6 years ago

Hi @stefl - any recommendations on how to pass data between pages on Gatsby? The plan right now is to POST to AirTables data at 2 points on the three step form:

  1. After the first step of the form (name and email)
  2. At the end of the form

This will allow @Rob1Paul to capture leads who have started the form but not completed it and possibly remarket to them.

Any thoughts on how we can pass the data between the pages? We've used Redux in the past but wasn't sure if there's a better way with Gatsby?

stefl commented 6 years ago

Personally, I'd look at using a React ContextProvider. I noticed that on signup that your form is split into three, and going back shows empty fields.

I do this in gatsby-browser.js:

export const wrapRootElement = ({ element }) => {
  const App = () => {
    return (
      <ApolloProvider client={client}>
        <SignupContextProvider>
          {element}
        </SignupContextProvider>
      </ApolloProvider>
    )
  }

  return (<App />)
}

And then you can make a SignupContextProvider and subscribe to its context in your signup form.

matthall8 commented 6 years ago

Awesome. Thanks for this @stefl - I will look into React context today.