How to write inheritance with stimulus controller ?
See original GitHub issue// javascript/packs/controllers/parent_controller.js
import { Controller } from "stimulus"
export class ParentController extends Controller {
myParentFunction(){
}
}
// javascript/packes/controllers/child_controller.js
import { ParentController } from "parent_controller.js"
export default class extends ParentController {
connect(){
console.log("child controller loaded!")
}
}
I have this error:
Uncaught TypeError: Super expression must either be null or a function, not object
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to write inheritance with stimulus controller ? #94 - GitHub
Resolved, just remove brackets in child controller file. 8
Read more >Mixins - Better StimulusJS
Stimulus controllers are meant to be used as mixins themselves (i.e. applying multiple controllers to one DOM element, thus mixing in behavior). Sometimes ......
Read more >Controllers - Stimulus Reference - Hotwire
Each controller class inherits from the Controller base class exported by the @hotwired/stimulus module.
Read more >Stimulus - Inheriting functionality - CodePen
// so we'll inherit the `connect()` & `static get targets()` functions. ... application.register("child", ChildController); !
Read more >Developers - How to write inheritance with stimulus controller ? -
javascript/packs/controllers/parent_controller.js import { Controller } from "stimulus" export class ParentController extends Controller ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resolved, just remove brackets in child controller file.
That should probably be more like: