Ejemplo n.º 1
0
  render: function () {
    return React.withContext(this.getCalendarCtx(), () => {
      var classes = this.className({
        modifiers: this.props.modifiers,
        classes: this.props.classes
      });

      var childrenMap = this.splitChildrenByDate(
        Week,
        dateUtils.monthEdges(this.props.date).map(this.createMonthEdge)
      );
      var weeks = dateUtils.weeksOfMonth(this.props.date).map(
        this.makeDirectChild.bind(this, childrenMap, Week)
      );

      var props = _.assign({
        className: classes()
      }, this.getEventHandlers());

      return React.DOM.div(props, [
        this.makeHeader(classes.descendant('header')),
        this.makeWeekHeader(classes.descendant('weekdays')),
        weeks
      ]);
    });
  }
Ejemplo n.º 2
0
 renderToString: function(router) {
   var string;
   React.withContext({router: router}, function() {
     string = React.renderToString(router.render());
   });
   return string;
 }
Ejemplo n.º 3
0
 return fetchDataDependencies(this.match).then(function(match)  {
   this.match = match;
   var context = {match:match, routing: this, routes: this.routes};
   return React.withContext(context, function()  {
     var view = createView(match);
     this.onRoute(view, match);
   }.bind(this));
 }.bind(this), this.onError);
Ejemplo n.º 4
0
		var children = React.Children.map(this.props.children, (child) => {
			var newChild = isReactVersion13()
				? React.withContext(this.getChildContext(), () => {
					return React.createElement(child.type, objectAssign({ key: child.key, ref: child.ref }, child.props));
				})
				: child;

			return newChild;
		});
Ejemplo n.º 5
0
  async function run() {
    /**
     * Like we did on the server, wait for data to be fetched before rendering.
     */
    await performRouteHandlerStaticMethod(state.routes, 'routerWillRun', state, flux);

    /**
     * Pass flux instance as context
     */
    React.withContext(
      { flux },
      () => React.render(<Handler />, document.getElementById('app'))
    );
  }
Ejemplo n.º 6
0
  return matchRoutes(routes, path).then((match) => {
    // either we had no matched route or route has not view attached
    if (!match.route || !match.route.view) {
      return undefined;
    }

    var context = {routes, match};

    if (additionalContext) {
      mergeInto(context, additionalContext);
    }

    return React.withContext(context, () => match.route.view(match.props));
  });
Ejemplo n.º 7
0
 render: function () {
   return React.withContext({
     kineticContainer: this.getKineticNode()
   }, function () {
     var children = React.Children.map(
       this.props.children,
       function (child) {
         return cloneWithProps(child, {});
       }.bind(this)
     );
     return React.DOM.div({},
       React.DOM.div({ref: 'canvas'}),
       children
     );
   }.bind(this));
 }
Ejemplo n.º 8
0
server.use(mount("/", function *( next ) {

    //ignore api and static routes
    if ( this.path.startsWith("/dist") ) {
        return yield next;
    }

    var _this = this;

    // Per request/session
    var context = app.createContext();
    var actionContext = context.getActionContext();
    var executeAction = thunkify(actionContext.executeAction);

    // Execute navigation action
    try {
        yield executeAction(navigateAction, {url: _this.path});
    } catch ( err ) {
        if ( err.status === 404 ) {
            this.throw(404);
        }

        this.throw(500, 'Error happened.');
    }

    var AppComponent = app.getAppComponent();

    React.withContext(context.getComponentContext(), function() {

        var html = React.renderToStaticMarkup(HtmlComponent({
            title: "react-ratchet",
            state: stateHelper.shareState(app, context),
            markup: React.renderToString(AppComponent({
                context: context.getComponentContext()
            }))
        }));
        //set the body
        _this.body = html;

    });

    yield next;

}));
Ejemplo n.º 9
0
  render: function () {
    return React.withContext(this.getCalendarCtx(), () => {
      var classes = this.className({
        modifiers: this.props.modifiers,
        classes: this.props.classes
      });
      var childrenMap = this.splitChildrenByDate(Month);
      var months = this.getMonthRange().map(
        this.makeDirectChild.bind(this, childrenMap, Month)
      );

      var props = _.assign({
        className: classes()
      }, this.getEventHandlers());

      return React.DOM.div(props, [
        this.makeHeader(classes),
        months
      ]);
    });
  }
Ejemplo n.º 10
0
router.use((transition, contexts) => {
  // use React context feature to pass in router into every
  // React component in this app, so that they could use it to
  // generate links and initiate transitions.
  // (Not to be confused with the context data for each route
  // that we loaded using fetchData and pass into each RouteHandler
  // as props)
  React.withContext({router: router}, () => {
    let childRouteHandler;
    // start rendering with the child most route first
    // working our way up to the parent
    let i = transition.routes.length - 1;
    _.clone(transition.routes).reverse().forEach((route) => {
      let RouteHandler = route.RouteHandler;
      let context = contexts[i--];
      childRouteHandler = <RouteHandler {...context}>{childRouteHandler}</RouteHandler>;
    });
    // when we finish the loop above, childRouteHandler
    // contains the top most route, which is the application
    // route. Let's render that into the page
    var app = childRouteHandler;
    React.render(app, document.body);
  });
});
Ejemplo n.º 11
0
  render: function () {
    return React.withContext(this.getCalendarCtx(), () => {
      var classes = this.className({
        modifiers: this.props.modifiers,
        classes: this.props.classes
      });

      var childrenMap = this.splitChildrenByDate(Day);
      var days = dateUtils.daysOfWeek(this.props.date).map(
        this.makeDirectChild.bind(this, childrenMap, Day)
      );

      var props = _.assign({
        className: classes()
      }, this.getEventHandlers());

      return React.DOM.div(props, [
        this.makeWeekNumber(classes),
        <div key="days" className={classes.descendant('days')}>
          {days}
        </div>
      ]);
    });
  }
Ejemplo n.º 12
0
 renderInto: function(router, element) {
   React.withContext({router: router}, function() {
     React.render(router.render(), element);
   });
 },
Ejemplo n.º 13
0
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

// This file bootstraps the entire application.

var ChatApp = require('./components/ChatApp.react');
var ChatExampleData = require('./ChatExampleData');
var ChatWebAPIUtils = require('./utils/ChatWebAPIUtils');
var ThreadStore = require('./stores/ThreadStore');
var MessageStore = require('./stores/MessageStore');
var React = require('react');

var threadStore = new ThreadStore();
var messageStore = new MessageStore(threadStore);

window.React = React; // export for http://fb.me/react-devtools


React.withContext({
  threadStore: threadStore,
  messageStore: messageStore
}, function () {
  React.render(
    <ChatApp />,
    document.getElementById('react')
  );
});


ChatExampleData.init(); // load example data into localstorage
ChatWebAPIUtils.getAllMessages();