Last active
January 9, 2017 22:28
-
-
Save jpomykala/751cd9ad21122ad696d15a3321cf9445 to your computer and use it in GitHub Desktop.
https://www.youtube.com/watch?v=fq02r-M-D8I // Redux Ty stara kurwo zmarnowałaś mi 20 lat życia
This file contains 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
class LoginPage extends Component { | |
test() { | |
this.props.setLoginState(SignInState.SIGNED_IN) | |
} | |
render() { | |
//... wywołuję test() po naciśnięciu przycisku | |
} | |
} | |
const mapDispatchToProps = (dispatch) => { | |
return (bindActionCreators({ | |
setLoginState: setLoginState | |
}, dispatch)); | |
}; | |
export default connect(null, mapDispatchToProps)(LoginPage); |
This file contains 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
import {LOGIN} from '../actionTypes' | |
export function setLoginState(signState) { | |
return {type: LOGIN, signState} | |
} |
This file contains 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 LOGIN = 'LOGIN' | |
export const LOGOUT = 'LOGOUT' |
This file contains 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
import {SignInState} from '../states'; | |
import {LOGIN, LOGOUT} from '../actionTypes'; | |
const initialState = { | |
signIn: SignInState.SIGNED_OUT | |
} | |
export default function login(state = initialState, action) { | |
switch (action.type) { | |
case LOGIN: | |
return {signIn: SignInState.SIGNED_IN}; | |
case LOGOUT: | |
return {signIn: SignInState.SIGNED_OUT}; | |
default: | |
return state; | |
} | |
} |
This file contains 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 SignInState = { | |
SIGNED_IN: 'SIGNED_IN', | |
SIGNED_OUT: 'SIGNED_OUT' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment