Skip to content

Instantly share code, notes, and snippets.

View cpojer's full-sized avatar

Christoph Nakazawa cpojer

View GitHub Profile
import ReactRouterRelay from 'react-router-relay';
// ...
React.render(
<Router
history={new BrowserHistory()}
createElement={ReactRouterRelay.createElement}>
<Route
name="home" // added a name to the route
<!doctype html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
}
iframe {
bottom: 0;
<RelayRootContainer
Component={Component}
route={{name, params, queries}}
/>
<Link href={getURIBuilder(ProfileRoute).setString('id', user.id).getURI()}>
{user.name}
</Link>
function matchRoute<T>(
route: {name: string},
map: {[key: string]: () => T}
): ?T {
return map[route.name] ? map[route.name]() : null;
}
// Usage
matchRoute(this.props.route, {
'ProfileRoute': () => <Profile {...props} />,
import relayNestedRoutes from 'relay-nested-routes';
const NestedRootContainer = relayNestedRoutes(React, Relay);
React.render(
<Router history={new BrowserHistory()}>
<Route component={NestedRootContainer}>
<Route
name="home" // added a name to the route
path="/"
@cpojer
cpojer / app.js
Last active February 8, 2016 02:40
import {Router, Route} from 'react-router';
import BrowserHistory from 'react-router/lib/BrowserHistory';
import App from './components/App';
import Widget from './components/Widget';
// A wrapper to create a Relay container
function createRelayContainer(Component, props) {
if (Relay.isContainer(Component)) {
// Construct the RelayQueryConfig from the route and the router props.
/**
* @providesModule LJPEG
*/function c(a){throw a;}var k=void 0,m=!0,s=null,u=!1,v;v||(v=eval("(function() { try { return Module || {} } catch(e) { return {} } })()"));var aa={},w;for(w in v)v.hasOwnProperty(w)&&(aa[w]=v[w]);var ba="object"===typeof process&&"function"===typeof require,ca="object"===typeof window,da="function"===typeof importScripts,ea=!ca&&!ba&&!da;
if(ba){v.print=function(a){process.stdout.write(a+"\n")};v.printErr=function(a){process.stderr.write(a+"\n")};var fa=require.call(null, "fs"),ga=require.call(null, "path");v.read=function(a,b){var a=ga.normalize(a),d=fa.readFileSync(a);!d&&a!=ga.resolve(a)&&(a=path.join(__dirname,"..","src",a),d=fa.readFileSync(a));d&&!b&&(d=d.toString());return d};v.readBinary=function(a){return v.read(a,m)};v.load=function(a){ha(read(a))};v.arguments=process.argv.slice(2);module.exports=v}else ea?(v.print=print,"undefined"!=typeof printErr&&
(v.printErr=printErr),v.read="undefined"!=typeof read?read:function(){c("no read() available (jsc?)")},v.readBinary=f
module.exports = function(file, api) {
var j = api.jscodeshift; // alias the jscodeshift API
var root = j(file.source); // parse JS code into an AST
// the main update method replaces merge with ObjectExpression
const update = path =>
j(path).replaceWith(j.objectExpression(
flatten(path.value.arguments.map(p =>
p.type == 'ObjectExpression'
? p.properties
instance.extend("parseImportSpecifiers", function (inner) {
return function (node) {
node.importKind = "value"
if (this.isContextual("type") || this.type === tt._typeof) {
if (this.type === tt._typeof) {
node.importKind = "typeof"
this.eat(tt._typeof)
}