2.1.0 • Published 9 years ago
@shiftboard/responsive-redux v2.1.0
Responsive Redux Module
Install
# Using Git:
yarn add git+ssh://git@github.com:shiftboard/responsive-redux.git
# Using private registry
yarn add @shiftboard/responsive-reduxUsage
Then import responsiveHandler into project wherever your redux store is (probably routes.js):
import {responsiveHandler} from '@shiftboard/responsive-redux'The responsiveHandler function attaches an event listener to the window object. When the browser is resized, the handler dispatches the viewport width (found using innerWidth) to the redux store. When calling the function, you must pass in the redux store as a parameter:
import store from 'app/redux/store'
responsiveHandler(store)Finally, import the responsiveReducer function wherever your combineReducers fuction call is:
import {responsiveReducer} from '@shiftboard/responsive-redux'
const reducer = combineReducers({
screenSize: responsiveReducer
})