从hashHistory react-router-redux中删除queryKey

时间:2016-07-01 17:33:40

标签: reactjs redux react-router react-redux react-router-redux

我发现有几个地方要设置queryKey: false,但我找不到用我正在使用的特定包设置的地方。这是我目前的设置:

import { hashHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import createStore from './store/createStore'

const store = createStore(initialState, hashHistory)
const history = syncHistoryWithStore(hashHistory, store, {
  selectLocationState: (state) => state.router
})

1 个答案:

答案 0 :(得分:3)

{queryKey:false}

的示例
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import reducers from '<project-path>/reducers'

import { createHashHistory } from 'history'
import { Router, Route, useRouterHistory } from 'react-router'

import { syncHistoryWithStore, routerReducer,routerMiddleware, push } from 'react-router-redux'


// Apply the middleware to the store
const reduxRouterMiddleware = routerMiddleware(browserHistory)

const store = createStore(
    combineReducers({
      ...reducers,
      routing: routerReducer
  }),
  initialState,
  applyMiddleware(reduxRouterMiddleware)
)
//set { queryKey: false }
const appHashHistory = useRouterHistory(createHashHistory)({ queryKey: false })

// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(appHashHistory, store)

ReactDOM.render(
  <Provider store={store}>
    { /* Tell the Router to use our enhanced history */ }
    <Router history={history}>
      <Route path="/" component={App}>
        <Route path="foo" component={Foo}/>
        <Route path="bar" component={Bar}/>
      </Route>
    </Router>
  </Provider>,
  document.getElementById('mount')
)