Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

dhl/meteor-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React smart package for Meteor

React Version: 0.8.0

meteor-react is a smart package for Meteor that provides integration for React.

React's add-ons are available.

Quick Start

mrt add react

Usage

Creating React components

Write your React components in files with .jsx extension.

foobar.jsx

Connecting Meteor's reactive states to React's

To receive reactive data from Meteor, add MeteorMixin as a mixin to the React component that should receive state updates, and implement the getMeteorState method by making use of any reactive data source from Meteor:

// foobar.jsx

var Foo = React.createClass({
    mixins: [MeteorMixin],

    getMeteorState: function() {
        return {
            // update React's this.state.bar by value of Session.get('bar')
            bar: Session.get('bar');
        };
    }
});

The state will be available as a property of this.state.meteor.

For example, to access bar in the component Foo above, we can do:

// foobar.jsx

var Foo = React.createClass({
    ...
    render: function() {
        var bar = this.state.meteor.bar;
        return (<span>{bar}</span>);
    }
    ...
});

Refer to the Interactivity and Dynamic UIs Guide for an explanation of how state works in React.

Credits

meteor-react is based on meteor-react by @benjamn and react-meteor by @petehunt.

License

Copyright (c) 2014 David Leung and contributors. See LICENSE.md for further details.

About

React mixins and bindings for Meteor

Resources

License

Stars

Watchers

Forks

Packages