Skip to content

Latest commit

 

History

History

change-title

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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 })