Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isServerCall = serverPath !== undefined && serverPath !== null;
const routePathes = pick(userRoutesActions, isString);
const initialRouteDispatch = !initialState || isServerCall; // call or not initial route
// Create a Dispatcher function for your composite Store:
const dispatcher = createDispatcher(
store,
getState => [
thunkMiddleware(getState),
multiActionMiddleware({wait: isServerCall}), // wait multiple actions to complete or not
promiseMiddleware(),
callFnMiddleware(action => (action && action.type === SWITCH_LINK && gotoRoute(action.url))) // helper for component
]
);
const redux = createRedux(dispatcher, initialState);
// bind route changes on changeRoute action
router(routePathes, initialRouteDispatch, (...args) => {
const dispatchResult = redux.dispatch(userRoutesActions.changeRoute(...args));
// resolve on server after all actions in userRoutesActions.changeRoute resolved
if (isServerCall) {
if (!dispatchResult || !isFunction(dispatchResult.then)) {
reject(new Error('dispatchResult must be promise on server'));
}
if (dispatchResult && isFunction(dispatchResult.then)) {
dispatchResult.then(
() => resolve(redux), // result is'n needed it's just to be sure all actions done
err => reject(err)
);
}
const {
Application,
Login,
Jobs,
Racks,
JobsMap,
Partitions,
QOS,
Reservations
} = components
const dispatcher = createDispatcher(
composeStores(stores),
getState => [ thunkMiddleware(getState), loggerMiddleware ]
)
const redux = createRedux(dispatcher)
export default class Root extends React.Component {
static propTypes = {
history: PropTypes.object.isRequired
}
constructor () {
super()
}
renderRoutes (history) {
let router = (
var React = require('react')
var {Redirect, Router, Route} = require('react-router')
var {createRedux} = require('redux')
var {Provider} = require('redux/react')
var LessonsApp = require('./LessonsApp')
var stores = require('../stores/index')
var redux = createRedux(stores)
var App = React.createClass({
render() {
var {history} = this.props
return
{renderRoutes.bind(null, history)}
}
})
function renderRoutes(history) {
return
}
export default function(initialState = {}) {
return createRedux(dispatcher, initialState)
}
import React from 'react';
import { createRedux } from 'redux';
import { Provider } from 'redux/react';
import * as stores from '../stores';
import ChatApp from './ChatApp';
const redux = createRedux(stores);
export default class App {
render() {
return (
{() => }
);
}
}
import Example from "actions/example"
import React from "react"
import Router, { Route, Redirect } from 'react-router'
import App from 'app'
import { createRedux } from 'redux';
import Provider from "redux/react"
import * as stores from "stores"
const redux = createRedux(stores);
var routes = (
)
React.initializeTouchEvents(true)
Router.run(routes, Router.HistoryLocation, (Handler) => {
React.render(, document.body)
})
export default function create(stores, initialState) {
const store = composeStores(stores);
const dispatcher = createDispatcher(store, () => [middleware()]);
return createRedux(dispatcher, initialState);
}
function renderRoute(routerState, transition) {
const redux = createRedux(dispatcher, {});
var bundleScriptSrc = 'assets/bundle.js';
var appScriptSrc = config.isProduction ? bundleScriptSrc : `${config.webpackDevUrl}/${bundleScriptSrc}`;
return Promise.all(RouteToInitialData(redux, routerState))
.then(()=> {
var appHtml = React.renderToString();
var scriptsHtml = `
`;
var title = 'A Title';
return buildHtmlPage(scriptsHtml, appHtml, title);
});
}
export default function(client, data) {
const dispatcher = createDispatcher(
store,
getState => [middleware(client)]
);
return createRedux(dispatcher, data);
}
import { loadLists } from './actions/listActions';
import * as components from './components';
import * as stores from './reducers';
import injectTapEventPlugin from 'react-tap-event-plugin';
import mui from 'material-ui'
let ThemeManager = new mui.Styles.ThemeManager();
ThemeManager.setTheme(ThemeManager.types.LIGHT);
const {
Application,
ListsView,
ListView
} = components;
const redux = createRedux(stores);
redux.dispatch(loadLists());
injectTapEventPlugin();
export default class Root extends React.Component {
static propTypes = {
history: PropTypes.object.isRequired
}
getChildContext() {
return {
muiTheme: ThemeManager.getCurrentTheme()
};
}
render() {