Manuel:viewmodel broken with latest updates?

Sorry… beats me. But there must be something…

1 Like

Yeah, it’s strange… but thanks a lot for trying to help out!

Latest beta has a fix for it:
meteor update --release 1.4.3.2-beta.0

1 Like

Waiting for 1.4.3.2, i solved it like this :

Template.registerHelper(‘asArray’,function(obj){
return obj && obj.array();
});

{{#each asArray yourreactiveArray}}
{{/each}}

Wasn’t 1.4.3.2 released 2 days ago?

1 Like

Hi!
Meteor updated to 1.4.3.2 (with observe-sequence@1.0.16) gives me following:

Uncaught TypeError: bindArg.element.addEventListener is not a function
at Object.bind (modules.js?hash=fa16d8f…:44518)
at Function.bindSingle (modules.js?hash=fa16d8f…:42337)
at modules.js?hash=fa16d8f…:42324
at attachRef (modules.js?hash=fa16d8f…:27735)
at Object.ReactRef.attachRefs (modules.js?hash=fa16d8f…:27757)
at ReactCompositeComponentWrapper.attachRefs (modules.js?hash=fa16d8f…:27561)
at CallbackQueue.notifyAll (modules.js?hash=fa16d8f…:27455)
at ReactReconcileTransaction.close (modules.js?hash=fa16d8f…:37729)
at ReactReconcileTransaction.closeAll (modules.js?hash=fa16d8f…:28614)
at ReactReconcileTransaction.perform (modules.js?hash=fa16d8f…:28561)

Please make a repro.

here is the repo
https://bitbucket.org/nchudnovets/kriya_temp

I’m sorry but that’s a full app. Please create a new app and add the bare minimum to reproduce the error.

yes, sorry
here is the same app, simplified to only 2 pages and 1 collection
all extra stuff deleted
it renders a part of content for home page and returns an error, mentioned above

There’s still a gazillion files in there. It’s very hard to troubleshoot a problem when there are so many files. Please create a new app and add the bare minimum to reproduce the error. Hopefully there will only be one component without extra CSS or HTML elements/tags/classes beyond what’s necessary to reproduce the problem.

Edit: So no routers, collections (use a simple array if necessary), helpers, etc. and no extra packages.

Yes, I understand the problem, but there is another problem. Simple app doesn’t have any problems :slight_smile:
Ok, I have been playing with the code for a while and found, that the issue is inside the createContainer() function and only if you use following pattern:

const SomeContainer = createContainer(() => {
  const dataHandle = Meteor.subscribe('pubName');
  const loading = !dataHandle.ready();
  const foo = Foo.find().fetch();
  const dataExists = !!loading && !!games; 
  
  return {
    foo,    
    dataExists
  };
}, ContentComponent);

and inside your component:

ContentComponent({  
  render(){
    return(
      <div>
        <Spinner b="unless: dataExists" />
        
        <div b="if: dataExists">
           some content
        </div>
      </div>
    );
  }  
});

the main line is this "const dataExists = !!loading && !!games; "
and the main point is “!!loading”. If you delete it, everything is ok.

I updated the repo and left there really minimum set of files where the problem appears

What’s the purpose of createContainer?

it provides reactive data to the component
it is the way suggested by official guide for Meteor + React
https://guide.meteor.com/react.html#using-createContainer

Oh! I just noticed I have a misprint above. Not !!loading but !loading (one exclamation mark)
but anyway the issue is with subscribtion.ready() method.
And probably it is not really VM issue as far as it is not inside a components.
It is possible to avoid using this method, so I am refactoring my code now to delete all this subscribtion.ready() from my containers.
So, not a problem.

But another issue I found is really about VM.
Now after meteor updating the ‘parent’ property of component ( this.parent() ) returns ‘undefined’.

Okay, how do you repro it?

updated repo
inside imports/ui/components there is Content component which is the parent for Button component.
Button uses parent’s ‘isClicked’ property
tested on Meteor 1.4.2.7 and works great
but with 1.4.3.2 Button returns to console “Cannot read property ‘isClicked’ of undefined”

It doesn’t look like it’s a problem with VM. Take the following repo and add the bare minimum to reproduce the error: https://github.com/ManuelDeLeon/viewmodel-react-starter-meteor

App({
	render() {
		<div>
			<input b="check: isChecked" type="checkbox" />
			<Button />
		</div>
	}
});
Button({
	render(){
		<button b="toggle: parent.isChecked">Toggle Parent</button>
	}
})

Resolved!
It is because of babel presets
deleted from .babelrc line ’ “presets”: [“es2015”, “react”], ’ and everything works fine now, including subscription.ready()
Thank you for your time and efforts.

Please update your docs, you still have there in the Installing block:

And update your babel configuration to use the plugin. The Babel configuration is usually in the .babelrc file but can also be in the Babel section of package.json

{

“presets”: [“es2015”, “react”],
“plugins”: [ “viewmodel-react-plugin” ]
}