0

I am trying a hello world app using react-native, Meteor and xvonabur/ react-native-meteor. I am trying to subscribe to the data from MongoDB.

server code :

 import {Mongo} from 'meteor/mongo';
    import {Meteor} from 'meteor/meteor';

    export const Pokemon = new  Mongo.Collection('pokemon');

    Meteor.publish('pokemon', () => {
        return Pokemon.find({});
    });

Client code:

export default createContainer(params=>{
    Meteor.subscribe('pokemon');

    return{
        pokemon: Meteor.collection('pokemon').find({})
    };
}, PokeMap);

As I understood after reading previous posts on stackoverflow, I have to define export const Pokemon = new Mongo.Collection('pokemon'); in a common scope to both server and the client. My client and the server are in Two different folders.

I tried to import pokemon.js in to the client as follow,

import { Pokemon } from '../../pokeserver/imports/collections/pokemon.js'

and tried to use it as follow;

export default createContainer(params=>{
    Meteor.subscribe('pokemon');

    return{
        pokemon: Pokemon.find({}),
    };
}, PokeMap);

But I am getting following error,

undefined Unable to resolve module `../../pokeserver/imports/collections/pokemon.js` from `Src\PokeMap.js`:
dennypanther
  • 53
  • 1
  • 10

1 Answers1

0

I think your import is wrong. You are doing an export default, which means that you don't need the brace around Pokemon

import Pokemon  from '/imports/collections/pokemon.js'

Should do the trick

Mikkel
  • 7,693
  • 3
  • 17
  • 31