Code Monkey home page Code Monkey logo

meteor-react-js's Introduction

Meteor React JS

This package is based on the @meteorrn/core package for React Native. Some little adjustments to make it work in the browser. All credits for the awesome work should go to the maintainers of the original package for React Native. Feel free to comment, contribute and fix. A hook version called Meteor.useTracker is also available.

A set of packages allowing you to connect your React app to your Meteor server, and take advantage of Meteor-specific features like accounts, reactive data trackers, etc. Compatible with the latest version of React.

Full API Documentation

Installation

npm install --save @nyby/meteor-react-js

Basic Usage

import Meteor from '@nyby/meteor-react-js';

// "mycol" should match the name of the collection on your meteor server
let MyCol = new Meteor.Mongo.Collection('mycol');

// Note the /websocket after your URL
Meteor.connect('wss://myapp.meteor.com/websocket'); 

class App extends React.Component {
  render() {
    let { myThing } = this.props;

    return (
      <div>
        <span>Here is the thing: {myThing.name}</span>
      </div>
    );
  }
}

let AppContainer = Meteor.withTracker(() => {
  Meteor.subscribe('myThing');
  let myThing = MyCol.findOne();

  return {
    myThing,
  };
})(App);

export default AppContainer;

Custom hooks

There are also custom hooks for managing subscriptions and calling Meteor methods implemented.

Meteor.usePublication

const [data, loading] = Meteor.usePublication({
  name: 'publication.name',
  params: { id: _id },
  fetch: () => MyCol.findOne({ _id: id }),
});

Meteor.useMethod

const { result, loading } = Meteor.useMethod('method.name', { id: _id });

meteor-react-js's People

Contributors

therealnate avatar mokto avatar jkthinksmart avatar xwz avatar spencercarli avatar simonbelanger avatar noris666 avatar charpeni avatar fakenickels avatar vermiculite avatar nauzer avatar faridsafi avatar babakscript avatar ujwal-setlur avatar polariswt avatar radiegtya avatar antoinegrandchamp avatar pomelyu avatar zhangtaii avatar josephdburdick avatar lyquocnam avatar malithjkmt avatar constambeys avatar rj-david 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.