Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

TypeError: Class constructor AutoForm cannot be invoked without 'new' #103

Open
rafaeltuelho opened this issue Dec 27, 2021 · 4 comments
Open

Comments

@rafaeltuelho
Copy link

my project dependencies are:

  "dependencies": {
    "@patternfly/react-core": "^4.162.3",
    "@patternfly/react-icons": "^4.13.1",
    "@patternfly/react-styles": "^4.12.5",
    "ajv": "^8.8.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "simpl-schema": "^1.12.0",
    "uniforms": "^3.7.0",
    "uniforms-bridge-json-schema": "^3.7.0",
    "uniforms-bridge-simple-schema-2": "^3.7.0",
    "uniforms-patternfly": "^4.7.4"
  }

and I'm getting the following error when using AutoForm from uniforms-patternfly

Uncaught TypeError: Class constructor AutoForm cannot be invoked without 'new'
    at new _ (webpack-internal:///./node_modules/uniforms-patternfly/dist/esm/AutoForm.js:15)
    at constructClassInstance (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:12716)
    at updateClassComponent (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:17425)
    at beginWork (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:19073)
    at HTMLUnknownElement.callCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:3994)
    at invokeGuardedCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:4056)
    at beginWork$1 (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:23959)
    at performUnitOfWork (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:22771)
    at workLoopSync (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:22702)

@rafaeltuelho
Copy link
Author

rafaeltuelho commented Dec 27, 2021

found this old issue on uniforms projects repo but it was related to metor. Not sure if it applies to patternfly and/or aerogear:
vazco/uniforms#433

@riccardo-forina
Copy link
Contributor

This happened to me often in the past, it's likely caused by multiple versions of uniforms in your project. You can check it using nvm ls uniforms or yarn why uniforms.

If you have multiple versions of it, you should try to pin the dependencies so as to have all the versions aligned. I rarely managed to fix the problem this way, but it might help you.

@tarilabs
Copy link

tarilabs commented Feb 2, 2022

I had the same issue as @rafaeltuelho

I did not have multiple versions of uniforms:

$ npm ls uniforms
[email protected] /Users/mmortari/git/... .../demogui
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]

It seems to me instead using import as:

import { AutoForm } from "uniforms-patternfly/dist/es6";

solved the Class constructor AutoForm cannot be invoked without 'new' problem for me.

@rafaeltuelho
Copy link
Author

Thanks for pointing this out @tarilabs . Will give it a try.

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

No branches or pull requests

3 participants