# Ember component creation error in 2.10

**URL:** <https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087>\
**Category:** Uncategorized\
**Created:** [December 12, 2016, 9:38pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087 "2016-12-12T21:38:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![webdo\_mane](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@webdo\_mane](https://discuss.emberjs.com/u/webdo_mane)\
**Post date:** [December 12, 2016, 9:38pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/1 "2016-12-12T21:38:08Z")

</div>

When I do Ember.Component.Create() in an unit test for mixin i get this error. I was upgrading ember from 1.13 to 2.10, this test worked fine in 1.13 but in 2.10 I get this error. Looks like in 2.10 ember component init requires an app instance.

```auto
Died on test #1 at Module.callback (http://localhost:4200/assets/tests.js:250:19)
    at Module.exports (http://localhost:4200/assets/vendor.js:131:32)
    at requireModule (http://localhost:4200/assets/vendor.js:30:18)
    at TestLoader.require (http://localhost:4200/assets/test-support.js:7104:7)
    at TestLoader.loadModules (http://localhost:4200/assets/test-support.js:7096:14)
    at Function.TestLoader.load (http://localhost:4200/assets/test-support.js:7126:22)
    at http://localhost:4200/assets/test-support.js:7009:18: Cannot instantiate a component without a renderer. Please ensure that you are creating <(subclass of Ember.Component):ember210> with a proper container/registry.@ 9 ms
Source: 	
Error: Cannot instantiate a component without a renderer. Please ensure that you are creating <(subclass of Ember.Component):ember210> with a proper container/registry.
    at Class.init (http://localhost:4200/assets/vendor.js:51954:15)
    at Class.superWrapper [as init] (http://localhost:4200/assets/vendor.js:50175:22)
    at Class.init (http://localhost:4200/assets/vendor.js:50443:19)
    at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
    at Class.init (http://localhost:4200/assets/vendor.js:50493:19)
    at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
    at Class.exports.default._emberMetal.Mixin.create._Mixin$create.init (http://localhost:4200/assets/vendor.js:51000:17)
    at Class.superWrapper (http://localhost:4200/assets/vendor.js:50175:22)
    at Class.init (http://localhost:4200/assets/vendor.js:17472:19)
    at Class.superWrapper [as init] (http://localhost:4200/assets/vendor.js:50175:22)

```

Few things I have tried:

- To startApp() in setup and destroy, similar to integration testing
- To override init but init always requires \_super() to be called
- Tried to execute in integration testing environment where application is created

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [December 13, 2016, 6:39am UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/2 "2016-12-13T06:39:55Z")

</div>

Perhaps take a look at this code:

[https://github.com/aupac/ember-aupac-typeahead/pull/31/commits/179a8650792aa33111eb5dd8dfdad2aa6819f0d4](https://github.com/aupac/ember-aupac-typeahead/pull/31/commits/179a8650792aa33111eb5dd8dfdad2aa6819f0d4)

---

<div class="post-metadata">

**Author:** ![webdo\_mane](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@webdo\_mane](https://discuss.emberjs.com/u/webdo_mane)\
**Post date:** [December 13, 2016, 8:09pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/3 "2016-12-13T20:09:11Z")

</div>

thank you the code definitely gave a lead but i am not sure where to get the renderer from. I created a new ember app and tried to fetch from there but it does not have one. I tried using unit test context but that does not have it too. Finally i did renderer: {}. This made sure that the check did not fail. Since i did not have a necessity to use rendering anywhere this fixed the issue for now. Thanks again

---

<div class="post-metadata">

**Author:** ![boris](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/boris/32/12457_2.png) [@boris](https://discuss.emberjs.com/u/boris)\
**Post date:** [December 15, 2016, 9:09am UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/4 "2016-12-15T09:09:00Z")

</div>

What I did was:

```
var owner = Ember.getOwner(this);
var renderer = owner.lookup('renderer:-dom');

```

And pass this ‘renderer’ variable as renderer to Component.create. This is probably a horrible hack, but it works.

---

<div class="post-metadata">

**Author:** ![webdo\_mane](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@webdo\_mane](https://discuss.emberjs.com/u/webdo_mane)\
**Post date:** [December 15, 2016, 5:16pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/5 "2016-12-15T17:16:52Z")

</div>

awesome, will try that too

---

<div class="post-metadata">

**Author:** ![whynot](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@whynot](https://discuss.emberjs.com/u/whynot)\
**Post date:** [February 3, 2017, 2:06pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/6 "2017-02-03T14:06:20Z")

</div>

Look great. But where are these codes should be written? and demo code will be wonderful . very thanks.

---

<div class="post-metadata">

**Author:** ![steveszc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/steveszc/32/10051_2.png) [@steveszc](https://discuss.emberjs.com/u/steveszc)\
**Post date:** [April 12, 2017, 8:25pm UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/7 "2017-04-12T20:25:04Z")

</div>

The ideal solution here for Ember 2.12+ is to lookup the component factory and create a new component from the factory.

`needs: ['component:my-component']`

`const MyComponent = Ember.getOwner(this).factoryFor('component:my-component');`

`MyComponent.create()`

---

<div class="post-metadata">

**Author:** ![boris](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/boris/32/12457_2.png) [@boris](https://discuss.emberjs.com/u/boris)\
**Post date:** [April 13, 2017, 8:18am UTC](https://discuss.emberjs.com/t/ember-component-creation-error-in-2-10/12087/8 "2017-04-13T08:18:01Z")

</div>

@steveszc - I’m not sure exactly what you mean. The code that I’m using is something like:

```
template = '<div></div>'

owner = Ember.getOwner(this)
component = Ember.Component.create
  layout: Ember.HTMLBars.compile(template)
  renderer: owner.lookup('renderer:-dom')
Ember.setOwner(component, owner)

component.setProperties({ foo: 1, bar: 2 })

component.append()

```

This code is for creating dynamic components (with dynamic layouts). I’m not sure where your code would fit here, could you please elaborate?
