This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createSelector } from 'reselect' | |
| export default createSelector([ | |
| state => state.location.type, | |
| state => state.location.payload, | |
| state => state.videosHash, | |
| state => state.videosByCategory.categories, | |
| ], | |
| (type, { slug, category }, videosHash, videosByCategory) => { | |
| if (type === 'VIDEO') return !videosHash[slug] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default (state = { cache: {} }, action = {}) => { | |
| switch (action.type) { | |
| case 'LIST': { | |
| const { category } = action.payload | |
| return { | |
| ...state, | |
| current: category, | |
| loading: !state.cache[category] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const components = { | |
| Home: universal(() => import('./Home'), { | |
| resolve: () => require.resolveWeak('./Home'), | |
| }), | |
| List: universal(() => import('./List'), { | |
| resolve: () => require.resolveWeak('./List'), | |
| }), | |
| Video: universal(() => import('./Video'), { | |
| resolve: () => require.resolveWeak('./Video'), | |
| }), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const components = { | |
| Home: universal(() => import('./Home'), { | |
| resolve: () => require.resolveWeak('./Home'), | |
| }), | |
| List: universal(() => import('./List'), { | |
| resolve: () => require.resolveWeak('./List'), | |
| }), | |
| Video: universal(() => import('./Video'), { | |
| resolve: () => require.resolveWeak('./Video'), | |
| }), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const requireWeak = (modulePath) => { | |
| try { | |
| const moduleId = require.resolveWeak(modulePath) | |
| return __webpack_require__(moduleId) | |
| } | |
| catch (err) { | |
| return null | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| externals: !isNode ? [] : | |
| fs.readdirSync(path.resolve(__dirname, '../../node_modules')) | |
| .filter( | |
| x => !/\.bin|react-universal-component|webpack-flush-chunks|^normalize.css/.test(x), | |
| ) | |
| .reduce((externals, mod) => { | |
| externals[mod] = `commonjs ${mod}`; // eslint-disable-line | |
| return externals; | |
| }, {}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import createHistory from 'history/createMemoryHistory' | |
| import { NOT_FOUND } from 'redux-first-router' | |
| import configureStore from '../src/configureStore' | |
| export default async (req, res) => { | |
| const history = createHistory({ initialEntries: [req.path] }) | |
| const { store, thunk } = configureStore(history) | |
| let location = store.getState().location | |
| if (doesRedirect(location, res)) return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import createHistory from 'history/createMemoryHistory' | |
| import { NOT_FOUND } from 'redux-first-router' | |
| import configureStore from '../src/configureStore' | |
| export default async (req, res) => { | |
| const history = createHistory({ initialEntries: [req.path] }) | |
| const { store, thunk } = configureStore(history) | |
| // perhaps request + dispatch app-wide state as well: | |
| // await Promise.all([ store.dispatch(myThunkA), store.dispatch(myThunkB) ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import createHistory from 'history/createMemoryHistory' | |
| import { NOT_FOUND } from 'redux-first-router' | |
| import configureStore from '../src/configureStore' | |
| export default async (req, res) => { | |
| const history = createHistory({ initialEntries: [req.path] }) | |
| const { store, thunk } = configureStore(history) | |
| await thunk(store) // THE PAYOFF! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import createHistory from 'history/createMemoryHistory' | |
| import { NOT_FOUND } from 'redux-first-router' | |
| import configureStore from '../src/configureStore' | |
| export default async (req, res) => { | |
| const history = createHistory({ initialEntries: [req.path] }) | |
| const { store, thunk } = configureStore(history) | |
| await thunk(store) // THE PAYOFF! |