-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
uniforms-material 2.6.0: TypeError: Cannot read property 'prototype' of undefined #638
Comments
i remember this problem to beeing related to circular dependencies |
Hi @macrozone. I've seen the same problem while updating our documentation. Can you somehow reproduce it elsewhere? It just works in our projects and documentation. |
@radekmie could not reproduce it in the example of https://github.com/react-page/react-page It happens in my project. proably because i needed to force webpack to transpile uniforms. |
It'd be great if you could provide a reproduction, or at least a full stack trace along with the relevant parts of the files (including their names, to know if it uses ES5 or ES6 build) so I could at least try help you. |
at the moment i stick with 2.5.0, it seems that the initial problem no longer occures with 2.5.0. I have to move on now on the project and will revisit this problem in some weeks. Maybe others will have similar problems, let's see. |
I've got the same issue in one project with I was able to trace the issue down to the babel and filed an issue. Not sure when it will be fixed. The problem seems to be related to the generated by tsc // es6/QuickForm.js
...
getNativeFormProps() {
// local variable name shadowing generated class name
const _a = super.getNativeFormProps(), { autoField: AutoField = this.getAutoField(), errorsField: ErrorsField = this.getErrorsField(), submitField: SubmitField = this.getSubmitField() } = _a, props = tslib_1.__rest(_a, ["autoField", "errorsField", "submitField"]);
if (!props.children) {
props.children = this.getChildContextSchema()
.getSubfields()
.map((key) => React.createElement(AutoField, { key: key, name: key }))
.concat([
React.createElement(ErrorsField, { key: "$ErrorsField" }),
React.createElement(SubmitField, { key: "$SubmitField" })
]);
}
return props;
} After _createClass(_a, [{
key: "getNativeFormProps",
value: function getNativeFormProps() {
// notice class variable name is shadowed by local variable name
var _a = _get(_getPrototypeOf(_a.prototype), "getNativeFormProps", this).call(this),
_a$autoField = _a.autoField,
AutoField = _a$autoField === void 0 ? this.getAutoField() : _a$autoField,
_a$errorsField = _a.errorsField,
ErrorsField = _a$errorsField === void 0 ? this.getErrorsField() : _a$errorsField,
_a$submitField = _a.submitField,
SubmitField = _a$submitField === void 0 ? this.getSubmitField() : _a$submitField,
props = tslib_1.__rest(_a, ["autoField", "errorsField", "submitField"]);
if (!props.children) {
props.children = this.getChildContextSchema().getSubfields().map(function (key) {
return _react["default"].createElement(AutoField, {
key: key,
name: key
});
}).concat([_react["default"].createElement(ErrorsField, {
key: "$ErrorsField"
}), _react["default"].createElement(SubmitField, {
key: "$SubmitField"
})]);
}
return props;
} This issue actually prevents using library when the code is transpiled by babel. |
I have found out the same thing while updating our docs project and that made me updating Docusaurus, which is using a newer version of Babel. It worked, but maybe it’s still a configuration (plug-ins, etc.) problem. |
@radekmie It only depends on if you will compile dependencies or not. CRA based apps do it. So it will likely create a problem with any cra based application. I will try to come up with a repo demonstrating the issue. |
@radekmie here you go. A repo demonstrating the issue https://github.com/Tarabyte/uniforms-cra-issue. It is using
The issue arise when compiling the production build. Try |
Thanks, @Tarabyte. As I can see, it's the same issue as @yuryturing has already reported to Babel. |
@radekmie Yeah, that's my personal account :) @Tarabyte === @yuryturing Just made a repo as promised so we could check the fix later ;) |
Sure thing. It just hit me though - it's a TypeScript bug, not a Babel one, as we do use |
Hmm, actually the code generated by const Quick = (parent) => { var _a; return _a = class extends parent {
b() {
// the next line throws "Cannot read property 'prototype' of undefined"
const _a = super.b();
return _a + 1;
}
},
_a.Quick = Quick,
_a;
};
class A {
b() {
return 1
}
}
const B = Quick(A)
const b = new B()
console.log(b.b()) |
Right, I thought that maybe it's not spec-compliant, but after a few checks it's all fine - Babel step fails. |
Same issue on 2.6.1. With 2.5.0 works. |
I had to rollback from 2.6.0 to 2.5.0 to avoid that undefined error. But after that run into the issue #641 in my tests:
|
@chomamateusz Have you tried it with the latest uniforms and Babel? We do use uniforms in our docs (duh!) and it just works. |
@radekmie If I use 2.5.0 it runs to globalThis error in tests. If I use 2.6.1 it fails to render forms due to that :/ |
I was using node 10 in my ci runner, which doesn't have globalThis. Upgrading to node 12 works. |
Babel is not really into solving our issue, therefore I'll work on a workaround tomorrow. |
Fixed by 1df4a88 and released in v2.6.6. |
Hi, TypeError: Cannot read property 'prototype' of undefined |
@atcg01 I m running into the same problem, did you find a solution? |
for my case, as a workaround, I had to downgrade to version 2.5.0 |
Hi @atcg01. I somehow missed your message! Thanks, @ziedmahdi for this ping. Yeah, I see it may cause problems in the same way. And as I see, the Babel issue is not yet fixed. OK then, could any of you file a new issue? We'd take care of it soon. |
it seems that uniforms 2.6.0 broke uniforms-material, at least if you use it inside of another library. I get this error:
The text was updated successfully, but these errors were encountered: