Пример #1
0
import { default as React } from 'react'
import { render } from 'react-dom'
import { renderToString } from 'react-dom/server'
import { createMemoryHistory } from 'history'
import { Router, RouterContext, match, browserHistory } from 'react-router'
import { default as routes } from './routes'
import { Html } from './components'
import { default as createStore } from './redux/create'
import { Provider } from 'react-redux'
import { default as canUseDOM } from 'can-use-dom'
import { default as withScroll } from 'scroll-behavior/lib/withStandardScroll'
import { syncHistoryWithStore } from 'react-router-redux'

if (canUseDOM) {
    let history = withScroll(browserHistory)
    const store = createStore(history)
    history = syncHistoryWithStore(history, store)
    render(
        <Provider store={store}>
            <Router
                history={history}
                routes={routes}
            />
        </Provider>,
        document.getElementById('content')
    )
}

export default ({ assets, path }, callback) => {
    const history = createMemoryHistory()
    const store = createStore(history)
Пример #2
0
require('setimmediate')

var createHashHistory = require('history/lib/createHashHistory')
var React = require('react')
var {render} = require('react-dom')
var Router = require('react-router/lib/Router')
var useRouterHistory = require('react-router/lib/useRouterHistory')
var withScroll = require('scroll-behavior/lib/withStandardScroll')

var routes = require('./routes')

var history = withScroll(useRouterHistory(createHashHistory)())

render(<Router history={history} routes={routes}/>, document.getElementById('app'))