Created
April 20, 2016 09:33
-
-
Save morizotter/81dbc2cccb91086fc490248178270da0 to your computer and use it in GitHub Desktop.
React+Reduxをした時のwindowサイズの変更検知 ref: http://qiita.com/morizotter/items/db22f9f2507a65956bf9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const changeScreenWidth = (width) => { | |
return { | |
type: 'CHANGE_SCREEN_WIDTH', | |
screenWidth: width, | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
... | |
screenWidth: window.innerWidth, | |
}; | |
const sampleApp = (state = initialState, action) => { | |
switch (action.type) { | |
... | |
case 'CHANGE_SCREEN_WIDTH': | |
return Object.assign({}, state, { | |
screenWidth: action.screenWidth, | |
}); | |
default: | |
return state; | |
} | |
}; | |
export default sampleApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment