Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-resolver

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-resolver

Isomorphic library to lazy-load data for React components

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
increased by31.03%
Maintainers
1
Weekly downloads
 
Created
Source

React Resolver https://img.shields.io/npm/v/react-resolver.svg

Isomorphic library to lazy-load data for React components

Checkout the examples!

Status

This project is undergoing eager, active development :)

  • Define props as static.resolve
    • Resolve props that are Promises
    • Resolve props that have callbacks
    • Resolve props that are synchronous
  • Server-side rendering
  • Client-side rendering
    • With state changes

Installation

$ npm install --save react-resolver
var Resolver = require('react-resolver');

Usage

1. Specify Props to Lazy-Load

var UserView = React.createClass({
  statics: {
    resolve: {
      // Return a Promise
      user: function() {
        return UserStore.find(this.getParams().userId);
      },

      // or use a Callback
      user: function(done) {
        request.get(`/users/${this.getParams().userId}`, done);
      }
    }
  },
  ...
});

2. Wrap your <Route />

Assuming you're using React Router, you'll need to wrap your routes to maintain context:

var resolver  = require('resolver').create();
var routes    = resolver.route(require('./routes'));

This makes it possible for your statics.resolve props to access Router.State, Router.Navigation, and other contexts.

3. Resolve & Render

var resolver  = require('resolver').create();
var routes    = resolver.route(require('./routes'));

Router.run(routes, function(Handler) {
  resolver.handle(Handler).then(function(resolved) {
    // On the Client
    React.render(resolved, document.getElementById('app'));

    // on the Server
    res.send(React.renderToStaticMarkup(resolved));
  });
});

Authors

License

Keywords

FAQs

Package last updated on 18 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc