facebookarchive / react-meteor

React rendering for Meteor apps
948 stars 114 forks source link

Errors running: meteor run android #54

Closed giantelk closed 9 years ago

giantelk commented 9 years ago

Using Mac OS X, I get the following errors running: meteor run android. I can run other Blaze meteorJS projects OK in the Android simulator, but not this react-meteor leaderboard example. See errors below, btw: I did meteor update to v1.1, and this ReactJS example works OK in Chrome browser.

users-MacBook-Pro:leaderboard carlf$ meteor run android
[[[[[ ~/Documents/dev/meteor/react-meteor/examples/leaderboard ]]]]]

=> Started proxy.                             
=> Started app on Android Emulator.           
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3000/
I20150331-22:39:48.835(-4) (android:http://meteor.local/leaderboard.jsx.js:8) Uncaught ReferenceError: React is not defined
I20150331-22:39:48.931(-4) (android:http://meteor.local/packages/blaze.js:2977) Uncaught Error: No such template: Leaderboard
I20150331-22:39:48.956(-4) (android:http://meteor.local/packages/blaze.js:2977) Uncaught Error: No such template: Leaderboard
ukabu commented 9 years ago

Same issue for me using Linux.

My guess is that inject-react.js is never actually used on the client. In package.js, this file is added only for "server" and never for client. I guess it works on web cause the initial page rendering is done on the server and thus React is properly loaded.

idris commented 9 years ago

@giantelk any luck with this? I'm seeing the same problem with iOS.

ukabu commented 9 years ago

I've made it to work on my local setup... Not tested with server-side rendering so I'm not sure if it's covers everything. So my modification are not ready for a pull-request.

Currently, the package tries to load the minified react when building for prod. It's done with a quick hack that generate a script tag. This will never work on Cordova. This hack is also not really useful because Meteor is going to minify all the javascript when building for production.

So my fix is to just add the unminified react-with-addons js to the client and export the React object.

I'll try to test and clean-up my fix to submit a pull-request, however I can't promise a time-frame.

Meanwhile, you can use this gist to apply my fix to a local copy of the package.

idris commented 9 years ago

@ukabu thanks. That fixes the problem with React not being defined, but now React.addons is undefined. Any ideas?

ukabu commented 9 years ago

@idris That's weird, it seems to be properly defined for me, both on the client (web and cordova) and server. Do you have sample code?

idris commented 9 years ago

Oops, sorry.. I had messed something else up. Looks like your code works! Thanks!

giantelk commented 9 years ago

@idris I put my Meteor React stuff on hold for now, so no, haven't had chance to test this out again.