React Package for Meteor

I’ve seen a lot of different efforts out there to integrate React with Meteor and I’m seeing a lot of repetition.

  1. https://github.com/reactjs/react-meteor

(new users can only post 2 links per post, so I’ll put the rest in the comments)

I think we all ought coordinate a little better so we’re not constantly reinventing the wheel. As you can see, I’ve been working on a react package so here are some thoughts I’ve had to get the discussion going.

  1. I think there needs to be an official un-opinionated React package that simply includes the latest version of React on the server and the client. No Meteor mixins in this package so people are free to create their own. Since these seems to be a variety of opinions on compiling JSX (babel, harmony CJSX), it seems better to keep these packages separate as well.

  2. As for a the meteor mixin goes, there are a few features that I’ve found quite useful:
    2a) getMeteorState is much like Template.helpers and provides fine-grained reactivity:

getMeteorState: {
  posts: function() { ... }
  users: function() { ... }
}

2b) getMeteorSub allows you to create subscriptions. These could also be fine-grained reactive functions:

getMeteorSubs: {
  post: function() { ... }
  user: function() { ... }
}

2c) to leverage the fine-grained reactivity, we can transfer all props to reactive variables in this.rprops so we can do things like:

getMeteorSubs: {
  post: function() { return Posts.findOne(this.rprops.postId.get()) }
}

Let me know what you think about these points. I’m open to ideas. I just think that the whole community would be better off if we worked together rather than all building our own React-Meteor packages.

Cheers,

Chet

3 Likes
  1. https://github.com/ccorcos/meteor-react-utils
  2. https://github.com/hipertracker/meteor-reactjs/
  1. https://github.com/grigio/meteor-babel/
  2. https://github.com/grovelabs/meteor-react

How do you install this package? This gives “error: no such package”.

meteor add react

I believe that’s the ‘official’ react package that the MDG are cooking up. It’s not released yet, hence you can’t install it in the latest Meteor.

I also want to mention that I have since drifted away from using Meteor Mixins. Now, I use React always with Pure Render Mixin and a top-level component that receives the state of the entire app. I find that this is a really nice way to separate the view from the controller and other people seem to think that as well