Git Product home page Git Product logo

react-typeform-embed's Introduction

🚫 Unmaintained Repository

Please Note: This repository is no longer maintained.

For the latest and actively maintained version, please visit the official repository:

Typeform React Embed Library

Thank you for your support and understanding.

React Typeform Embed

A React wrapper for Typeform Embed SDK.

See a live demo.

Upgrading from v.0.3

Important: Please be aware that if you are updating this package from a version previous to v.1.0 you will need to apply changes in your implementation.

Usage

First install the package

yarn add react-typeform-embed

There are five different embed types that you can import as components.

  • Widget
  • Popup
  • Slider
  • Sidetab
  • Popover

Widget

With the widget embed type you can embed your form inline, in a DOM element.

import { Widget } from 'react-typeform-embed';

const App = () => {
  render() {
    return <Widget id="njdbt5" height={500} />;
  }
}

Popup and Slider

With the popup and slider embed types you can embed the form in a modal. You need to pass as children the element/s that will open the modal when clicked.

import { Popup /* or Slider */ } from 'react-typeform-embed';

const App = () => {
  return (
    <Popup id="njdbt5" size={80}>
      <button>Open Popup</button>
    </Popup>
  );
}

Sidetab and Popover

These other modal embed types work exactly as the Popup component but, since they are already visible and clickable, passing children element/s is optional.

import { Sidetab /* or Popover */ } from 'react-typeform-embed';

const App = () => {
  return <Sidetab id="njdbt5">
}

See the source for more examples.

Configuration

You need to provide the form id as id prop.

You can get the id from the public URL of your form URL (https://form.typeform.com/to/<form-id>) or admin panel URL (https://admin.typeform.com/form/<form-id>).

You can also use any other option and callback from the official SDK passing them as props. Find more info here:

<Widget
  id="your-form-id"
  height={400}
  opacity={80}
  hidden={{
    userId: 'hidden-user-id'
  }}
  onSubmit={() => {
    console.log('Form submitted!')
  }}
  hideHeaders
  disableAutoFocus
  enableSandbox
/>

Demo

See a live demo, or run:

git clone https://github.com/alexgarces/react-typeform-embed
cd react-typeform-embed
yarn
yarn start
open http://localhost:3000

Alternatives

License

Code released under the MIT license.

react-typeform-embed's People

Contributors

alexgarces avatar kikobeats avatar phlipper avatar scrofungulus avatar trandromeda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-typeform-embed's Issues

Example for React Functional Components

Hello,

I'm fairly new to react and looking into embedding a form as a pop-up. I'm using functional components and can't really figure out how to adapt the classic example for functional stateless components (espacially the ref part). Any chance you can provide us with a working example ?

Cheers

Form fields not saving data

When a form gets submitted, some answered questions are required to be answered again.

This is not a consistent problem, but it happens regularly.

Here is an example:

Let me know if you need more information.

[0.2.0] Page scrolling to <ReactTypeformEmbed /> component on load. Any workarounds?

Howdy!

On page load we're taken all the way to the bottom of the page and the user has to scroll all the way up. (So I position my ReactTypeformEmbed at the very bottom of the page, and then the user is scrolled to that component not after the component is loaded (tried fixing with a setScroll on the componentWillMount function), but after the (embedded) typeform pagee loads.

Here's a snippit for context:

        <div className={classNames(classes.main, classes.mainRaised)}>
          <div className={classes.container}>
            <ScrollableAnchor id={"about-us"}>
              <SectionAboutUs />
            </ScrollableAnchor>
            <SectionTeam style={{ marginTop: "-150px" }} />
            <ScrollableAnchor id={"faq"}>
              <SectionFAQ />
            </ScrollableAnchor>
            <ScrollableAnchor id={"schedule"}>
              <SectionSchedule />
            </ScrollableAnchor>
            <SectionSponsors />
            <ScrollableAnchor>
              <SectionWork /> {/* <ReactTypeformEmbed  LIVES HERE!!! /> */}
            </ScrollableAnchor>
          </div>
        </div>

Full source for that page found here: https://github.com/MarioLopezBaylor/wacode-site/blob/master/src/views/LandingPage/LandingPage.jsx

And here's the render function from the component:

  render() {
    const { classes } = this.props;
    return (
      <div className={classes.section}>
        <GridContainer
          justify="center"
          style={{ height: "475px", width: "100%" }}
        >
          <GridItem cs={12} sm={8} md={8}>
            <h2 className={classes.title}>Work with us</h2>
            <h4 className={classes.description}>
              Wacode is looking for sponsors and community partners. We want to
              find business and organizations who believe and support our
              mission of bringing technology to our local community, and
              providing a platform for our flourishing tech community.
            </h4>
            <ReactTypeformEmbed
              popup={false}
              url="https://wacodeteam.typeform.com/to/mpK8Ns"
            />
          </GridItem>
        </GridContainer>
      </div>
    );
  }

Full source for this other component found here: https://github.com/MarioLopezBaylor/wacode-site/blob/master/src/views/LandingPage/Sections/SectionWork.jsx

If you need more context, here's the full repo: https://github.com/MarioLopezBaylor/wacode-site

Maybe I'm being dumb about this? Let me know.

Thanks for looking into it!

Add support for missing embed modes

The Embed Modes offered in the app are Standard, Full-page, Popup, Slider, Popover, and Side Tab. This library appears to only support Popup (popup=true) and, I assume, Full-page (if popup=false). It appears the only way to use the others is to use the copy-and-paste code snippet in the admin.

Error when using with Typescript

When I import it the way it is shown in the README file. It gives the below error:

Could not find a declaration file for module 'react-typeform-embed'. 'path_in_node_mdulesreact-typeform-embed/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-typeform-embed` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-typeform-embed';`

It gives a 404 when I try to install with types.

Android Mobile Issues

The Typeform displays completely fine and pops up well, but when you go to type in the answer, it brings the keyboard up and then immediately shoves it back down. It does this every time you try to type so users are not able to finish the form.

Any others have this issue or any suggestions? I'll keep trying it on different Android devices.

Handle Errors

There are no error handlers like onError or something like this and when an error occurs, like this one:

Screenshot 2020-06-17 at 12 18 20

from my understanding, there is nothing one can do about it.

Touchscreen devices - Tablet/Mobile

on while filling up the Form.

Once I navigate back or to any page powered by react router I can't scroll or touch anymore on my website, it's like I'm locked.

It's exactly on the form if I was the user and decided to cancel the form and go away from that page.

Does anyone has experienced this?

Not working on mobile device

Hi! Thanks for contributing the code. Embedded Mode is awesome on PC but it does not work on a mobile device such as iPad.

Do you happen to know how to deal with it?

Weird refresh

I've just tried this component on a simple page with a div and the Typeform as the single child. I cannot make it work without this annoying refresh: http://sendvid.com/chc8cy5p

I have tried removing the classes from the div. Is this related to some internal <input> tag?

<div className={'container-fluid-content pay'}>
    <ReactTypeformEmbed url={'LINK'}/>
</div>

No PostCSS Config found error

Any idea how to respond to this bug?

Error in ./~/react-typeform-embed/lib/ReactTypeformEmbed/ReactTypeformEmbed.css Module build failed: Error: No PostCSS Config found in: /Users/xxxxxxx/auth0react/node_modules/react-typeform-embed/lib/ReactTypeformEmbed at <anonymous> @ ./~/react-typeform-embed/lib/ReactTypeformEmbed/ReactTypeformEmbed.css 4:14-153 18:2-22:4 19:20-159

Bug with 404

App crash when using widget with React Next.

This is due to the fact that the application collects the wrong link.

Screen Shot 2021-01-25 at 3 46 48 PM (2)

Wrong information autoClose props

autoClose PRO+ accounts only. Time until the embedded typeform should automatically close after a respondent clicks the Submit button. Your typeform will automatically close after the time you specify, so respondents won’t have to manually close your typeform popup. In seconds.Popup mode option N/A

onSubmit not working

I have the PRO + account and I'm trying to print the result of the onSubmit callback but its undefined.

This is my code right now:

class TypeForm extends React.Component {
  onSubmit(args) {
    console.log('onSubmit', args);
  }
  render() {
    return (
      <div className="type-form''>
        <ReactTypeformEmbed
          onSubmit={this.onSubmit}
          popup={false}
          url={this.props.url}/>
      </div>
    );
  }
};

Thanks in advance.

Form submission is caching in localstorage

I have embedded a typeform inside a webpage. It works great, but one thing I've noticed is that it caches the form submission results, so that the next time the person submits the form, the values are pre-populated. I don't want the values to be pre-populated.

Is there a built in way to remove the cache, or do I have to remove it from local storage manually?

Typeform loads as a full page

Hi there,

Trying to add this to my gatsby project but running into an issue where the form loads a full page: https://5d1399e7729b99000785c917--jpvalery-portfolio.netlify.com/contact/
image

I tried adding a style="position:relative" but it didn't work

For reference, here's the contact.js page:

import React from 'react'
import { graphql } from 'gatsby'
import Helmet from 'react-helmet'
import config from '../utils/siteConfig'
import Layout from '../components/Layout'
import WrapperGrid from '../components/WrapperGrid'
import Hero from '../components/Hero'
import ContactBody from '../components/Contact/ContactBody'
import ContactBodyTop from '../components/Contact/ContactBodyTop'
import ContactBodyBottom from '../components/Contact/ContactBodyBottom'
import { ReactTypeformEmbed } from 'react-typeform-embed';
import SEO from '../components/SEO'

const Contact = ({ data, location }) => {
  const info = data.contentfulAbout
  return (
    <Layout location={location}>
      <Helmet>
        <title>{`${config.siteTitle} - Contact`}</title>
      </Helmet>
      <SEO postNode={info} pagePath="contact" customTitle pageSEO />
      <WrapperGrid>
        <Hero image={info.heroImage} />
        <ContactBody>
          <ContactBodyTop body={info.body} />
          <ContactBodyBottom>
            <ReactTypeformEmbed url="https://jpvalery.typeform.com/to/y96C4A" hideHeaders="true" hideFooter="true" opacity="0" style="position:relative;" />
          </ContactBodyBottom>
        </ContactBody>
      </WrapperGrid>
    </Layout>
  )
}

export const query = graphql`
  query {
    contentfulAbout {
      title
      id
      heroImage {
        title
        fluid(maxWidth: 1000) {
          ...GatsbyContentfulFluid_withWebp
        }
        ogimg: resize(width: 900) {
          src
          width
          height
        }
      }
      body {
        childMarkdownRemark {
          html
        }
      }
    }
  }
`

export default Contact

Any idea what I'm doing wrong?
How could I fix this so that the form stays in <ContactBodyBottom>?

Thanks a lot for your help!

onSubmit function for multiple typeform on one page

I am embedding 2 typeform in a single component. onSubmit function on both the component get called simultaneously even if I have submitted only first typeform.

import React from "react";
import { ReactTypeformEmbed } from "../components";

const ExampleWidget = () => {
  return (
    <div>
      <div>
        <ReactTypeformEmbed
          onSubmit={() => {
            console.log("typeform 1 submitted");
          }}
          url={"https://typeformdeviomedia.typeform.com/to/Cvc6N8"}
        />
      </div>
      <div>
        <ReactTypeformEmbed
          onSubmit={() => {
            console.log("typeform 2 submitted");
          }}
          url={"https://admin.typeform.com/to/cVa5IG"}
        />
      </div>
    </div>
  );
};

export default ExampleWidget;

popup=true breaks button onClick with default create-react-app

I'm not 100% on what the issue here is, or why, but just tried this library out and when I set popup={true}, any buttons in the same render block no longer seem able to run their onClick

"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-typeform-embed": "^0.1.5",
render() {
    return (
      <div className="ExamplePopup">
        <ReactTypeformEmbed
          popup={true}
          url={'https://demo.typeform.com/to/njdbt5'} />

        <button onClick={()=> alert(1)}>Foo</button>
      </div>
    )
  }

When I comment out the popup={true} I can click the button and get an alert, when I add it back in, nothing fires. Debugging with the react dev tools, I can see that the onClick event is still bound to it, and when I "store as global" and call it from the console, it fires correctly. So.. not sure what's going on here.

Edit: Trying to replicate this in a clone of this repo, changing/adding libraries/etc, and so far can't break it.. Non-deterministic issues!

Edit2: Ok, seem to be able to replicate this as follows:

create-react-app break
cd break
npm i react-typeform-embed

Create a new file ExamplePopup.js with code copied from this repo:

import React from 'react';
import { ReactTypeformEmbed } from 'react-typeform-embed';

class ExamplePopup extends React.Component {
  constructor(props) {
    super(props);
    this.openForm = this.openForm.bind(this);
  }

  openForm() {
    this.typeformEmbed.typeform.open();
  }

  render() {
    return (
      <div className="ExamplePopup">
        <ReactTypeformEmbed
          popup={true}
          autoOpen={false}
          url={'https://demo.typeform.com/to/njdbt5'}
          hideHeaders={true}
          hideFooter={true}
          buttonText="Go!"
          style={{top: 100}}
          ref={(tf => this.typeformEmbed = tf) }/>

        <button className="btn" onClick={this.openForm} style={{cursor: 'pointer'}}>Click to open the popup!</button>
      </div>
    );
  }
}

export default ExamplePopup;

Edit App.js to include the following additional lines:

import ExamplePopup from './ExamplePopup';

And in the render()

<ExamplePopup/>

Then npm start.

The button shows, but when you attempt to click on it, nothing happens.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.