Search code examples
meteormeteor-react

App does not render when ReactMeteorData mixin is present


I would like some advice with a strange problem. I created a minimal Meteor app with

meteor create testreactmeteordata  
cd testreactmeteordata  
meteor add react kadira:react-layout kadira:flow-router  
rm testreactmeteordata.*

and added following main.jsx file:

if (Meteor.isClient) {
    App = React.createClass({
        mixins: [ReactMeteorData],
        render() {
            return (
                <div>
                    <h1>App</h1>
                </div>
            )
        }
    });
}

FlowRouter.route('/', {
    name: 'Dashboard',
    action() {
        ReactLayout.render(App);
    }
});

This does not render anything, unless the mixins: line is removed!?

This are the versions used in this little project:

$ meteor list
autopublish           1.0.4  (For prototyping only) Publish the entire databa...
blaze-html-templates  1.0.1  Compile HTML templates into reactive UI with Met...
ecmascript            0.1.6* Compiler plugin that supports ES2015+ in all .js...
es5-shim              4.1.14  Shims and polyfills to improve ECMAScript 5 sup...
insecure              1.0.4  (For prototyping only) Allow all database writes...
jquery                1.11.4  Manipulate the DOM using CSS selectors
kadira:flow-router    2.10.0  Carefully Designed Client Side Router for Meteor
kadira:react-layout   1.5.3  Layout Manager for React with SSR Support
meteor-base           1.0.1  Packages that every Meteor app needs
mobile-experience     1.0.1  Packages for a great mobile user experience
mongo                 1.1.3  Adaptor for using MongoDB and Minimongo over DDP
react                 0.14.3* Everything you need to use React with Meteor.
session               1.1.1  Session variable
standard-minifiers    1.0.2  Standard minifiers used with Meteor apps by defa...
tracker               1.0.9  Dependency tracker to allow reactive callbacks


* New versions of these packages are available! Run 'meteor update' to try to
  update those packages to their latest versions. If your packages cannot be
  updated further, try typing `meteor add <package>@<newVersion>` to see more
  information.

Updating meteor does not really help:

2016-01-19 16:41 ~/src/meteor/testreactmeteordata
$ meteor update
This project is already at Meteor 1.2.1, the latest release.
Your top-level dependencies are at their latest compatible versions.

The following top-level dependencies were not updated to the very latest
version available:
 * react 0.14.3 (0.14.3_1 is available)

Newer versions of the following indirect dependencies are available:
 * jsx 0.2.3 (0.2.4 is available)
 * react-meteor-data 0.2.4 (0.2.5 is available)
To update one or more of these packages, pass their names to `meteor update`.

Trying to manually upgrade react as suggested shows a bunch of conficts:

2016-01-19 16:42 ~/src/meteor/testreactmeteordata
$ meteor add [email protected]_1
 => Errors while adding packages:

While selecting package versions:
error: Conflict: Constraint [email protected] is not satisfied by ecmascript
0.1.6.
Constraints on package "ecmascript":
* ecmascript@=0.1.6 <- top level
* [email protected] <- random 1.0.5 <- autoupdate 1.2.4 <- hot-code-push 1.0.0
<- meteor-base 1.0.1
* [email protected] <- random 1.0.5 <- minimongo 1.0.10 <- mongo 1.1.3
* [email protected] <- random 1.0.5 <- mongo 1.1.3
* [email protected] <- ddp-server 1.2.2 <- ddp 1.2.2 <- autoupdate 1.2.4 <-
hot-code-push 1.0.0 <- meteor-base 1.0.1
* [email protected] <- ddp-server 1.2.2 <- ddp 1.2.2 <- livedata 1.0.15 <-
meteor-base 1.0.1
* [email protected] <- ddp-server 1.2.2 <- ddp 1.2.2 <- meteor-base 1.0.1
* [email protected] <- templating 1.1.5 <- blaze-html-templates 1.0.1
* [email protected] <- caching-html-compiler 1.0.2 <- templating 1.1.5 <-
blaze-html-templates 1.0.1
* [email protected] <- caching-compiler 1.0.0 <- caching-html-compiler 1.0.2 <-
templating 1.1.5 <- blaze-html-templates 1.0.1
* [email protected] <- caching-compiler 1.0.0 <- cosmos:browserify 0.9.3 <-
kadira:flow-router 2.10.0
* [email protected] <- templating-tools 1.0.0 <- caching-html-compiler 1.0.2 <-
templating 1.1.5 <- blaze-html-templates 1.0.1
* [email protected] <- templating-tools 1.0.0 <- templating 1.1.5 <-
blaze-html-templates 1.0.1
* [email protected] <- reactive-dict 1.1.3 <- kadira:flow-router 2.10.0
* [email protected] <- jsx 0.2.4 <- react 0.14.3_1
* [email protected] <- coffeescript 1.0.11 <- cosmos:browserify 0.9.3 <-
kadira:flow-router 2.10.0

Please advise.

TIA,

Guido


Solution

  • You need to implement the getMeteorData method in your ReactComponent. Think about mixins like a interface. When you use in the class, that means your class is implementing it, thus needs a implementation