Giter Club home page Giter Club logo

Comments (10)

lucashu1 avatar lucashu1 commented on August 16, 2024 2

Getting a similar error with Next.js. My guess is that it has something to do with server-side rendering, but I'm not entirely sure.

I also tried importing the module using next/dynamic (with SSR disabled) instead of a regular import statement, but that didn't seem to fix it. Any pointers would be appreciated!

TypeError: _typeform_embed__WEBPACK_IMPORTED_MODULE_7__["makeWidget"] is not a function. (In '_typeform_embed__WEBPACK_IMPORTED_MODULE_7__["makeWidget"](elm, url, options)', '_typeform_embed__WEBPACK_IMPORTED_MODULE_7__["makeWidget"]' is undefined)

from embed.

HairMachine avatar HairMachine commented on August 16, 2024 2

I also see this in Vue. There is a createWidget function in there though! I'm not sure if it's the same thing or not; I get an InnerHTML error when I pass the element into that (this could still be user error on my part).

from embed.

psabbagh avatar psabbagh commented on August 16, 2024 1

I'm having the same issue in Gatsby on makePopup. The function is in there but for some reason it is giving below error:

undefined is not a function (near '..._typeform_embed__WEBPACK_IMPORTED_MODULE_2__.makePopup...')

from embed.

FullStackTiger avatar FullStackTiger commented on August 16, 2024 1

I am getting this error on gatsby project too.
TypeError: typeform_embed__WEBPACK_IMPORTED_MODULE_5_.makeWidget is not a function

from embed.

tunztunztunz avatar tunztunztunz commented on August 16, 2024

@lucashu1 @HairMachine

I was able to get this to work in React/Gatsby by running this code on the layout index.tsx:

  useEffect(() => {
    let mounted = true;
    if (mounted) {
      const initializeScripts = () => {
        loadScript("https://embed.typeform.com/embed.js", () => {
          () => {};
        });
      };
      initializeScripts();
    }
    return () => {
      mounted = false;
    };
  }, []);

Here's loadScript()

export const loadScript = (url: string, cb: GlobalEventHandlers["onload"]) => {
  const element = document.getElementsByTagName("script")[0];
  const fjs = element;
  const js = document.createElement("script");
  js.id = "widget-script";
  js.src = url;
  if (fjs && fjs.parentNode) {
    fjs.parentNode.insertBefore(js, fjs);
  } else {
    document.head.appendChild(js);
  }
  js.onload = cb;
};

And then I have my component with the link tag and SVG below this at the bottom of my layout index.tsx. I had to use this solution for another 3rd party script that wasn't working in React and figured this was the way. I'm not using this package at all. Hopefully, this will help anyone else having this issue.

from embed.

rrosztoczy avatar rrosztoczy commented on August 16, 2024

I got the same error trying to use makeWidget in my nextjs app. On inspection, I only have access to "createWidget" which I am using and it works.

from embed.

wamujlb avatar wamujlb commented on August 16, 2024

Have tried to use and it didn't work. I use simple react app without SSR. Does anyone know how this can be used in React?

from embed.

flppv avatar flppv commented on August 16, 2024

Had the same issue with React app. Had to revert the package version to a stable one: yarn add @typeform/[email protected]. It helped.

from embed.

wamujlb avatar wamujlb commented on August 16, 2024

@flppv decided to write my own small wrapper.

from embed.

mathio avatar mathio commented on August 16, 2024

Latest released version (>= 1) now works with server-side rendering. You can see a demo implementation in Next.js here.

from embed.

Related Issues (20)

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.