Skip to content

Instantly share code, notes, and snippets.

View mobinni's full-sized avatar

Mo Binni mobinni

  • Zero To Mastery
  • Toronto, Ontario
View GitHub Profile
@mobinni
mobinni / Item.jsx
Created December 16, 2015 21:01
A Modern Isomorphic Stack with Redux - Part 1
import React, {Component} from 'react';
class Item extends Component {
constructor(props, context) {
super(props, context);
}
render() {
const {params} = this.props;
return (
<div>Item: {params.item}</div>
@mobinni
mobinni / server.js
Last active December 17, 2015 23:39
A Modern Isomorphic Stack with Redux - Part 1
'use strict';
/**
* Created by mobinni on 07/12/15.
*/
require("babel/register")({
ignore: /node_modules/
});
// Browser variable declaration should be ignored by server
delete process.env.BROWSER;
@mobinni
mobinni / environment.js
Last active December 17, 2015 23:39
A Modern Isomorphic Stack with Redux - Part 1
'use strict';
const env = process.env.NODE_ENV || 'DEVELOPMENT';
// set env variable
const hasSSREnabled = (process.env.SSR || process.argv[2] === 'ssr') || false;
export default {
name: env,
isProduction: env === 'PRODUCTION',
isDevelopment: env === 'DEVELOPMENT',
ssrEnabled: hasSSREnabled
@mobinni
mobinni / index.js
Created December 16, 2015 21:38
A Modern Isomorphic Stack with Redux - Part 1
import env from './environment';
export default {
env
}
@mobinni
mobinni / webpack.js
Created December 16, 2015 21:42
A Modern Isomorphic Stack with Redux - Part 1
import WebPack from 'webpack';
import path from 'path';
import fs from 'fs';
import utils from '../utils';
import {StringDecoder} from 'string_decoder';
import webpackDevMiddleware from 'webpack-dev-middleware';
import HotReload from 'webpack-hot-middleware';
let webpackConfig = require(
`${__dirname}/../../webpack/webpack.${utils.env.isProduction ? 'prod' : 'dev'}.js`
@mobinni
mobinni / routing.js
Last active December 17, 2015 23:40
A Modern Isomorphic Stack with Redux - Part 1
/**
* Created by mobinni on 08/12/15.
*/
import webpack from './webpack';
import { match } from 'react-router';
import createLocation from 'history/lib/createLocation';
import {env} from '../utils';
import {renderEngine} from '../engines';
import routes from '../../app/scripts/routes';
@mobinni
mobinni / render.js
Last active December 17, 2015 23:33
A Modern Isomorphic Stack with Redux - Part 1
import {RoutingContext} from 'react-router';
import ejs from 'ejs';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
const _renderComponents = (props) => {
return ReactDOMServer.renderToString(
<RoutingContext {...props} />
);
};
@mobinni
mobinni / folder-structure.txt
Last active January 23, 2016 17:03
A Modern Isomorphic Stack with Redux - Part 2
.
├── app
│   ├── images
│   ├── index.html
│   ├── lib
│   │   ├── index.js
│   │   ├── middleware
│   │   ├── modules
│   │   │   ├── feed
│   │   │   │   ├── actions.js
@mobinni
mobinni / index.js
Last active January 27, 2016 15:10
A Modern Isomorphic Stack with Redux - Part 2
import actions from './actions';
import reducers from './reducers';
export default (config) => {
return {
actions: actions(config),
reducers,
name: 'feed'
};
};
@mobinni
mobinni / actions.js
Last active January 27, 2016 15:10
A Modern Isomorphic Stack with Redux - Part 2
export default function (config) {
return {
loadFeeds() {
return { type: 'get', payload: ['feed 1', 'feed 2', 'feed 3'] }
}
}
}