I am trying to convert React.js project to a next.js project.
I have this udf-compatible-datafeed.js file
import * as tslib_1 from "tslib";
import { UDFCompatibleDatafeedBase } from "./udf-compatible-datafeed-base";
import { QuotesProvider } from "./quotes-provider";
import { Requester } from "./requester";
var UDFCompatibleDatafeed = /** @class */ (function (_super) {
tslib_1.__extends(UDFCompatibleDatafeed, _super);
function UDFCompatibleDatafeed(datafeedURL, intradayFeedUrl, realTimeFeedUrl, enableLogging) {
var _this = this;
var requester = new Requester();
var quotesProvider = new QuotesProvider(datafeedURL, requester);
_this = _super.call(this, datafeedURL, intradayFeedUrl, realTimeFeedUrl, quotesProvider, requester, enableLogging) || this;
return _this;
}
return UDFCompatibleDatafeed;
})(UDFCompatibleDatafeedBase);
export default UDFCompatibleDatafeed;
Then inside my TVChartContainer.jsx file
const UDFCompatibleDatafeed = await import("./datafeeds/udf/src/udf-compatible-datafeed.js");
console.log("UDFCompatibleDatafeed", UDFCompatibleDatafeed);
console.log("3...");
const widgetOptions = {
//debug: true,
symbol: this.props.symbol,
// BEWARE: no trailing slash is expected in feed URL
datafeed: new UDFCompatibleDatafeed(
this.props.datafeedUrl,
this.props.intradayUrl,
this.props.realTimeUrl,
this.props.enableLogging
),
interval: this.props.interval,
};
This is my console logout put
And I am getting an error
TypeError: UDFCompatibleDatafeed is not a constructor
How do we identify whether this is a valid JS class or not?
I think just removing new will do the trick. you are returning a function, not a class.
datafeed: UDFCompatibleDatafeed(...)