Skip to content

Instantly share code, notes, and snippets.

@gazlu
Created September 18, 2016 17:17
Show Gist options
  • Save gazlu/4e9d120accb3789ca269dcd8e9062f81 to your computer and use it in GitHub Desktop.
Save gazlu/4e9d120accb3789ca269dcd8e9062f81 to your computer and use it in GitHub Desktop.
A wrapper class to access ReactJS components in ES-5 easily, access Router, Route, Link, EventEmitter and Flux.Dispatcher in ES-5
//Include following js files
//"/scripts/react/react.js",
//"/scripts/react/react-dom.js",
//"/scripts/react/ReactRouter.js",
//"/scripts/Flux/Flux.js",
//"/scripts/EventEmitter/EventEmitter.js",
/// <reference path="scripts/react/react.js" />
/// <reference path="scripts/react/react-dom.js" />
/// <reference path="scripts/react/ReactRouter.js" />
/// <reference path="scripts/Flux/Flux.js" />
/// <reference path="scripts/EventEmitter/EventEmitter.js" />
//React is globally available in the ES-5
//Create a global variable 'Router' to access Router in global scope in the ES-5
var Router = ReactRouter.Router;
//Create a global variable 'Route' to access Route in global scope in the ES-5
var Route = ReactRouter.Route;
//Create a global variable 'Link' to access Link in global scope in the ES-5
var Link = ReactRouter.Link;
//Create a global instance of 'EventEmitter' to access EventEmitter in global scope in the ES-5
var emitter = new EventEmitter();
//Create a global instance of 'Flux.Dispatcher' to access Dispatcher in global scope in the ES-5
var dispatcher = new Flux.Dispatcher();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment