Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 670 Bytes

File metadata and controls

31 lines (26 loc) · 670 Bytes

Automatically change <title> based on the route

// reducers/title.js
const DEFAULT = 'RFR demo'

export default (state = DEFAULT, action = {}) => {
  switch (action.type) {
    case 'HOME':
      return DEFAULT
    case 'USER':
      return `${DEFAULT} - user ${action.payload.id}`
    default:
      return state
  }
}
// reducers/index.js
export { default as title } from './title'
// configureStore.js
+ import * as reducers from './reducers'
  import page from './pageReducer'

- const rootReducer = combineReducers({ page, location: reducer })
+ const rootReducer = combineReducers({ ...reducers, page, location: reducer })