0

I have create a Base Backbone View (BaseView.js) using ES6 export default View.extend({}) and would like to use ES6 to then extend this view but having trouble doing this export default BaseView.extend({}) but I get ExtendedView is not a constuctor?

JS

// BaseView.js
export default View.extend({});
// ExtendedView.js
export default BaseView.extend({});
// Uncaught TypeError: ExtendedView is not a constructor
mikeapr4
  • 2,830
  • 16
  • 24
styler
  • 15,779
  • 23
  • 81
  • 135
  • "*`export default from BaseView.extend({})`*" is a syntax error. You need to put a string literal in the `from` part. – Bergi Mar 29 '17 at 09:44
  • Where exactly do you get that "is not a constructor" error? What is `ExtendedView`? – Bergi Mar 29 '17 at 09:45
  • The only way I can get this to work is by using module.exports = BaseView.extend({}); – styler Mar 29 '17 at 09:47
  • Try `new ExtendedView.default()`, you might be experiencing the same problem as http://stackoverflow.com/questions/33505992/babel-6-changes-how-it-exports-default – mikeapr4 Mar 29 '17 at 11:31

1 Answers1

0

I am working with backbone and ES6 using "module.exports" instead of "export".

module.exports = class YourView extends Backbone.View {}

I hope it helps.