Glue NetInfo from react-native to Redux.
npm install redux-middleware-react-native-netinfo[redux-middleware-react-native-netinfo][]
==========================================





Glue [NetInfo][] from [react-native][] to [Redux][].
npm install --save redux-middleware-react-native-netinfo
``js
// Just import the middleware and add it to your store
import { createStore, applyMiddleware } from 'redux';
import { middleware as netInfo } from 'redux-middleware-react-native-netinfo';
const createStoreWithMiddleware = applyMiddleware(netInfo)(createStore);
// And in your reducers receive the value
import { TYPE as NET_INFO } from 'redux-middleware-react-native-netinfo';
function netInfoReducer(state = {}, action) {
switch (action.type) {
case NET_INFO:
console.log('NetInfo:', action.payload);
default:
return state;
}
}
``
- Write tests for everything!
[Redux]: https://github.com/gaearon/redux
[redux-middleware-react-native-netinfo]: https://github.com/michaelcontento/redux-middleware-react-native-netinfo
[react-native]: https://facebook.github.io/react-native/
[NetInfo]: https://facebook.github.io/react-native/docs/netinfo.html#content