Skip to content

Instantly share code, notes, and snippets.

View c7tincu's full-sized avatar
🖤

Cristian Tincu c7tincu

🖤
  • Bucharest, Romania
View GitHub Profile
@c7tincu
c7tincu / style.js
Last active December 11, 2015 10:58
RequireJS style! plugin.
/* This is the Basic AMD Hybrid Format.
http://addyosmani.com/writing-modular-js/ */
define(
function (require, exports, module) {
"use strict";
/* Require the deps. */
var ø = require("euh-js");
var less = require("less");
WebSocket.prototype.oldSendImpl = WebSocket.prototype.send;
WebSocket.prototype.send =
function (data) {
console.log("\u2192 " + data);
this.oldSendImpl(data);
this.addEventListener(
"message",
function (msg) {
console.log("\u2190 " + msg.data);
getMaxDateImpl =
// Returns the maximum valid month day, given a year and a month.
function (year, month) {
return (
indexOf([ 0, 2, 4, 6, 7, 9, 11 ], month) !== - 1 ?
// January, March, May, July, August, October, or December.
31 :
indexOf([ 3, 5, 8, 10 ], month) !== - 1 ?
// April, June, September, or November.
30 :
// You’d expect this one…
render() {
return (
<button { ...this.props } className={ this.cn + (this.props.className ? ' ' + this.props.className : '') }>
{ this.props.children }
</button>
);
}

So I needed to transfer the routing context (I’m using react-router) from component X to component ContactsEditDialog, as it’s rendered in some remote area of the DOM tree (#modal), not under the node corresponding to component X, as usual...

So I basically replaced this...

React.withContext({ router: this.context.router }, () => {
  React.render(
    <ContactsEditDialog { ...this.props } { ...i18nData }/>,
    document.getElementById('modal')
 );