smfoote / ember-glimmer-component

Glimmer.js-like components in Ember
MIT License
9 stars 0 forks source link

component.trigger is not a function #3

Open chrism opened 6 years ago

chrism commented 6 years ago

I can use perfectly (with ember-decorators)

import { CompatComponent as Component } from 'ember-glimmer-component';
import { classNames } from '@ember-decorators/component';
import { computed } from '@ember-decorators/object';

@classNames('static-class')
export default class extends Component {
  @computed('@filename', '@filetype')
  get tomsterPath() {
    return `/img/${this.filename}.${this.filetype}`
  }
}

But when I try with (removing ember-decorators)

import { Component } from 'ember-glimmer-component';

export default class extends Component {
}

I get this error in the console

Uncaught TypeError: component.trigger is not a function
    at CurlyComponentManager.create (ember-glimmer.js:3696)

This is the line of code it refers to

component.trigger('didReceiveAttrs');

I'm using the latest version of canary and my templates are very basic to test with, just simple html without even any properties for now.

The code is available to see here: https://github.com/chrism/emberjs-2018/tree/glimmer-component

Any idea why this might be happening?

Much appreciated, thanks!

smfoote commented 6 years ago

Interesting. Perhaps something changed in the recent Ember releases.

harokevin commented 5 years ago

I had the same error but my problem was that I was importing Component from @ember/controller, not @ember/component'.

import Component from '@ember/controller';

I should have been using

import Component from '@ember/component';

kmccullough commented 4 years ago

I had the same error but my problem was that I was importing Controller from @ember/controller and extending from it, expecting a Component. If you convert a controller/tpl to a component, don't forget to actually change it to a component.