2016-01-16 16 views
5

aktarılmasından sonra tanımsız olarak Yönlendirici 2.0.0rc1-5 Ben browserHistory elde edilmiştir tepki tepki ile tanımsız sürüm ve sunucu veya istemci üzerinde olsun, aynı sonucu aldım.browserHistory Yönlendirici 2.00 sürüm adayları ile

Bu bilinen bir hata olabilir?

+0

, sen tarih yaratıcısı olsun “tarih” paketinden. [Dokümanlar] 'a bir göz atın (https://github.com/rackt/react-router/blob/1.0.x/docs/guides/basics/Histories.md). –

+1

Usta şubeden, aslında tarayıcı-tarayıcıyı şimdi tepki-yönlendiriciye dönüştürdüğüne inanıyorum. – hoodsy

+0

2.0 rcs ile, sunucuda tanımsız alıyorum ... ve tarayıcımda '' 'connect.js? 243b: 60 Uncaught TypeError: finalMapStateToProps bir işlev değil '' (bir Redux sorunu gibi görünüyor). Yönelticiyi '' 'renderToString''' – hoodsy

cevap

1

bakınız useRouterHistory: https://github.com/rackt/react-router/blob/master/upgrade-guides/v2.0.0.md#using-custom-histories

ben sunucu tarafı bu kullanıyorum:

import {Router, RouterContext, match, useRouterHistory} from 'react-router'; 
import {createMemoryHistory} from 'history'; 

// ... 
const appHistory = useRouterHistory(createMemoryHistory)({}); 
const component = (
    <Provider store={store} key="provider"> 
    <Router routes={routes} history={appHistory} /> 
    </Provider> 
); 
+1

'tepki-yönlendirici' sürüm 3.0 yükleyebilirsiniz, bunun gibi: 'npm install - karşı tepki-yönlendirici @ 3.0' da webpack yapılandırma dosyanızı güncellemelisiniz. Ve sen gitmek için iyisin. –

0

yükleyin tepki-yönlendirici sürüm 3.0

npm install --save [email protected] veya

yarn add [email protected]

Ardından her iki yöntemler işe:

Yöntem `tepki-router` yeni sürümlerinde ile 1

import { Router, useRouterHistory } from 'react-router'; 
import {createMemoryHistory} from 'history'; 
import routes from './routes'; 

const appHistory = useRouterHistory(createMemoryHistory)({}); 

ReactDOM.render(
    <Router history={appHistory} routes={routes}/>, 
    document.getElementById('root') 
); 

Yöntem 2

import { Router, browserHistory } from 'react-router'; 
import routes from './routes'; 

ReactDOM.render(
    // or hashHistory 
    <Router history={browserHistory} routes={routes}/>, 
    document.getElementById('root') 
);