Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _piwikpro_react_piwik_pro__WEBPACK_IMPORTED_MODULE_9___default(...).initialize is not a function #11

Open
niklasdohmen opened this issue Oct 4, 2022 · 7 comments

Comments

@niklasdohmen
Copy link

Hello! Somehow I get the webpack error even though it has been working for a few weeks now. I didn't changed something (neither webpack version, react-piwik package version or the relevant code parts).

TypeError: _piwikpro_react_piwik_pro__WEBPACK_IMPORTED_MODULE_9___default(...).initialize is not a function`

The relevant code follows the documentation, is initialized in the _app.tsx and looks like that:

`import PiwikPro from '@piwikpro/react-piwik-pro';
....
PiwikPro.initialize(PIWIK_PRO_APP_ID, PIWIK_PRO_INSTANCE);

I am using React 17.0.2 with Next.js 12.2.5. I already tried different ways of importing the module, but that didn't work out.

Does anybody know what the issue is here?

@danieltwork
Copy link
Contributor

@niklasdohmen

Hi, thanks for the notification. We tried to reproduce the problem, but with the standard react configuration the problem does not seem to occur.

Would you be willing to show us how you build your application? Maybe some minimal version of the webpack configuration file?

At the same time, I would like to inform you that we have released a new library to help integrate our product with NextJS applications. https://www.npmjs.com/package/@piwikpro/next-piwik-pro

@matthiasbruns
Copy link

I have the same problem when trying to use react-piwik-pro with next.js , so I tried using next-piwik-pro. The repo is not open to file a bug report, that's why I am doing this here now

Your SDK does not work - it fails with:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

How to reproduce:

  1. npx create-next-app@latest --ts
  2. npm install @piwikpro/next-piwik-pro
  3. replace contents of _app.tsx with the provided content below
  4. npm run dev
import PiwikProProvider from "@piwikpro/next-piwik-pro";
import { AppProps } from "next/app";

function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <PiwikProProvider accountName="accountName" containerId="43e4bca4-e220-43df-acfc-40fef7e25105">
        <Component {...pageProps} />
      </PiwikProProvider>
    </>
  );
}

export default App;

I wish you had a public repo for the lib.

@niklasdohmen
Copy link
Author

@matthiasbruns Same here, also tried the next-piwik-pro package and got the same "Element type is invalid" error...

@barlima
Copy link

barlima commented Dec 1, 2022

Facing the same errors for both react-piwik-pro and next-piwik-pro. Any progress on that?

@matthiasbruns
Copy link

Well. Drop Piwik. That's what I did. 28days and no response 🤣

@danieltwork
Copy link
Contributor

I have the same problem when trying to use react-piwik-pro with next.js , so I tried using next-piwik-pro. The repo is not open to file a bug report, that's why I am doing this here now

Your SDK does not work - it fails with:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

How to reproduce:

  1. npx create-next-app@latest --ts
  2. npm install @piwikpro/next-piwik-pro
  3. replace contents of _app.tsx with the provided content below
  4. npm run dev
import PiwikProProvider from "@piwikpro/next-piwik-pro";
import { AppProps } from "next/app";

function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <PiwikProProvider accountName="accountName" containerId="43e4bca4-e220-43df-acfc-40fef7e25105">
        <Component {...pageProps} />
      </PiwikProProvider>
    </>
  );
}

export default App;

I wish you had a public repo for the lib.

The repository has been made public. Link

Could you try the solution we wrote about in the README of the next-piwik-pro library? I have verified that it solves your problem, however I would like confirmation from you.

Solution

@niklasdohmen @barlima

@barlima
Copy link

barlima commented Dec 12, 2022

@danieltwork it helped, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants