How to navigate to home page after submitting the google form

Viewed 92

I need to integrate the google form inside my gatsby application. In onsubmit I have opened the google form. Once after filling the form details after submitting the form I need to take user to home page. I have tried using useNavigate and history I couldn't able to navigate the page to home. Can anyone guide me how to achieve this. Thanks in advance.

function GoogleLink() {
  let navigate = useNavigate()

  let openFrame = () => {
    let iframe = document.createElement("iframe")
    iframe.src = `googleform link`
    iframe.frameBorder = "0"
    iframe.id = "iframe"
    iframe.style.position = "absolute"
    iframe.style.zIndex = "999"
    iframe.style.height = "100%"
    iframe.style.width = "100%"
    iframe.style.top = "0"
    iframe.style.backgroundColor = "white"
    iframe.style.border = "none"
    document.body.prepend(iframe)
    document.body.style.overflow = "hidden"
  }

  const handleSubmit = () => {
    openFrame()
    navigate("/home")
  }
  return (
    <Layout>
      <div>
        <Row>
          <Col>
            <Button onClick={handleSubmit}>Click Here</Button>
          </Col>
        </Row>
      </div>
    </Layout>
  )
}
1 Answers

Just check the link for the home page is defined as /home or just simply replace it with /.

By default / routes to homepage

Related