GithubHelp home page GithubHelp logo

meteor-react's Introduction

updated version of luma:react-meteor with ReactJS 0.12.2

react-meteor

This repository defines a Meteor package that automatically integrates the React rendering framework on both the client and the server, to complement or replace the default Handlebars templating system.

The React core is officially agnostic about how you fetch and update your data, so it is far from obvious which approach is the best. This package provides one answer to that question (use Meteor!), and I hope you will find it a compelling combination.

Quick start

If you have not yet installed Meteor, do that:

curl https://install.meteor.com | /bin/sh

Clone this repository:

git clone https://github.com/benjamn/react-meteor.git

Fire up one of the examples:

cd react-meteor/examples/leaderboard
meteor

Finally, visit localhost:3000 in your browser. For extra fun, try using the example in multiple browser windows!

Adding the package to your app

Although the Meteor package API is deliberately undocumented and remains in flux before v1.0, here is how I currently recommend adding this package to your Meteor app:

cd path/to/my-app/
echo react >> .meteor/packages
git clone https://github.com/benjamn/react-meteor.git packages/react

If you want to share the package between multiple apps, you can clone it to a common location and make packages/react a symbolic link.

How it works

The package exposes a special ReactMeteor.Mixin object that can be used to enable reactive data fetching for your React components.

To add the ReactMeteor.Mixin to a React component, simply include it in the mixins class property:

var MyComponent = React.createClass({
  mixins: [ReactMeteor.Mixin],

  // Make sure your component implements this method.
  getMeteorState: function() {
    return {
      foo: Session.get("foo"),
      ...
    };
  }
});

The getMeteorState method should return an object of properties that will be accessed via this.state in the component's render method or elsewhere. Dependencies will be registered for any data accesses performed by getMeteorState so that the component can be automatically re-rendered whenever the data changes.

Alternatively, if you prefer not to declare mixins explicitly, you can create the class with ReactMeteor.createClass:

var MyComponent = ReactMeteor.createClass({
  // Make sure your component implements this method.
  getMeteorState: function() {
    return {
      foo: Session.get("foo"),
      ...
    };
  }
});

meteor-react's People

Contributors

jhartma avatar qdrk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.