I’ve been trying to do an import to pull data into a React component but it keeps telling me that Coupons are undefined. I looked in the mongo command line and I can see the record I inserted through astronomy with the MDG validated methods package. Any thoughts to why I would be getting coupons undefined from within getMeteorData()?
I tried it as Coupons and coupons but both return the same undefined.
Exact error: Uncaught ReferenceError: coupons is not defined
Component:
import React, {Component, Proptypes} from 'react';
import {ReactMeteorData} from 'meteor/react-meteor-data';
import reactMixin from 'react-mixin';
…
export default couponList = ({coupons}) => {
console.log(coupons);
return <div>{coupons._id}</div>
};
export default class adminHome extends Component {
getMeteorData() {
const handle = Meteor.subscribe('coupons');
console.log(this);
return {
Coupons: coupons.find() || {}
}
}
constructor(props) {
super(props);
}
renderCoupons() {
console.log(this.data.Coupons);
return this.data.Coupons.map((coupon) => {
return <div>ID: coupon._id</div>
});
}
render() {
return (
<div>
<div className="tempContainer">
<p className="header">Coupons</p>
<couponList coupons={this.data.Coupons} />
</div>
</div>
);
}
}
reactMixin(adminHome.prototype, ReactMeteorData);
Collection (In Lib Folder)
import {Meteor} from 'meteor/meteor';
import {Accounts} from 'meteor/accounts-base';
import {Mongo} from 'meteor/mongo';
import {Astro} from 'meteor/jagi:astronomy';
import {Validators} from 'meteor/jagi:astronomy-validators';
import {relations} from 'meteor/jagi:astronomy-relations';
import {timestamp} from 'meteor/jagi:astronomy-timestamp-behavior';
export const Coupons = new Mongo.Collection('coupons');
… Astro class stuff below …