ember-inspector
ember-inspector copied to clipboard
ember inspector fails for ember-redux wrapped components that have a null value
When a redux wrapped component has a null value in its stateToComputed
function ember-inspector fails with two errors (trying to read a property on null). Here's an example of a component that causes this:
import Component from '@ember/component';
import { connect } from 'ember-redux';
const stateToComputed = (state) => ({
computedField: null
});
const Qwerty = Component.extend({
});
export default connect(stateToComputed)(Qwerty);
I've got a simple branch that fixes this here: https://github.com/emberjs/ember-inspector/compare/master...StrangeLooperStudio:ember-redux-null-bug?expand=1
Probably not the best approach, but it stops inspector from crashing. computedField
above would show up in the inspector with a calculator icon but clicking the icon doesn't resolve the value to null.
@mattmarcum seems related to https://github.com/emberjs/ember-inspector/issues/999
That was an issue with ember-redux too. I'm not sure why a null value couldn't be valid here. Definitely need to look into this.
@rwwagner90 I did see that issue while researching this one. It did fix some of my other ember-redux related issues I saw. Do you want me to create a pr for that branch? If you could point me in the direction of a better fix I can investigate, I just don't have a lot of context on what's going on here. Looks like ember-redux isn't creating computed properties the way ember-inspector expects. Ember-redux creates an @ember/object#computed
during the component's init hook and applies it to the component with @ember/object#defineProperty
https://github.com/ember-redux/ember-redux/blob/master/addon/core.js#L85
@mattmarcum that's what #999 was about. ember-redux is making computeds on the class instance, which @pzuraq says should be changed in ember-redux.
Either way, we added in the necessary checks to make things work. Seems like we maybe just need to rethink things full null
values.