-
Notifications
You must be signed in to change notification settings - Fork 25
Connected React Router
Richard Davis edited this page Aug 23, 2020
·
1 revision
Synchronize router state with redux store through uni-directional flow (i.e.
history
->store
->router
->components
).
import React from 'react';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import App from './App';
// note: configuration of store, history, and reducers is intentionally omitted.
const Root = ({ history, store }) => {
return (
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>
);
};
export default Root;
Your state tree now has the following nodes:
const state = {
router: {
location: {
pathname: '/',
search: '',
hash: '',
key: '',
query: {}
},
action: ''
}
}
Subscribe to location changes app (e.g. - pathname
), and update state.
import { LOCATION_CHANGE } from 'connected-react-router';
const reducer = (state = initialState, action = {}) => {
switch (action.type) {
case LOCATION_CHANGE:
// ...
return {
...state,
updatedProp
}
default:
return state
}
}
export default reducer
- Team Working Agreement
- Team composition
- Workflows and processes
- Testing and bug filing
- Accessing eAPD
- Active Documentation:
- Sandbox Environment
- Glossary of acronyms
- APDs 101
- Design iterations archive
- MMIS Budget calculations
- HITECH Budget calculations
- Beyond the APD: From Paper to Pixels
- UX principles
- User research process
- Visual styling
- Content guide
- User research findings
- eAPD pilot findings
- User needs
- Developer info
- Development environment
- Coding Standards
- Development deployment
- Infrastructure Architecture
- Code Architecture
- Tech 101
- Authentication
- APD Auto Saving Process
- Resetting an Environment
- Hardware Software List
- Deploying Staging Production Instances Using Scripts
- Terraform 101 for eAPD
- Provisioning Infrastructure with Terraform
- WebSocket basics
- Operations-and-Support-Index
- Single Branch Deployment Strategy
- Ops and Support Overview
- Service Level AOI
- Incident Response Plan
- On-Call Policy
- Infrastructure Contingency Plan
- Updating CloudFront Security Headers
- Requesting and Installing TLS Certificates