Can't subscribe using createContainer


#1

I’m using Meteor again, with the >1.3 recommended folder structure.
The point is, I cannot subscribe using the createContainer approach.

Here’s my /imports/startup/client/routes.js file

import React from 'react';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { mount } from 'react-mounter';
import MainLayout from '../../ui/layouts/MainLayout';
import AppContainer from '../../ui/containers/AppContainer';

FlowRouter.route('/', {
	name: 'home',
	action(){
		mount(MainLayout, {content: <AppContainer  />});
	}
});

In /imports/api/workers/workers.js

import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';

const Workers = new Mongo.Collection('Workers');
export default Workers;

I declare the publication in /imports/api/workers/server/publications.js

import { Meteor } from 'meteor/meteor';
import Workers from '../workers';

Meteor.publish('allWorkers', () => Workers.find());

Here’s my container component in /imports/ui/containers/AppContainer.js:

import React from 'react';
import { Meteor } from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import Workers from '../../api/workers/workers';
import Homepage from '../pages/Homepage';

export default AppContainer = createContainer(({ params }) => {
	const handle = Meteor.subscribe('allWorkers'),
				loading = !handle.ready(),
				workers = Workers.find().fetch();
  return { loading, workers };
}, Homepage)

And here’s the component that should render the data, in /imports/ui/pages/Homepage.js

import React from 'react';

const Homepage = (props) => (
  <div>
  	<h1>{this.props.workers}</h1>
  </div>
);

export default Homepage;

When I go to that route, I get the console error: Uncaught TypeError: Cannot read property ‘workers’ of undefined at Homepage (Homepage.js:6), and when enter into the web console Workers.find().fetch(), I get this: _Uncaught ReferenceError: Workers is not defined.

Please help me fix this. What am I doing wrong?