Created
July 28, 2019 13:28
-
-
Save shoo7830/22308202dea7a9fe342d85b8f95452db to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/gatimuv
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.4/redux.js"></script> | |
| <script id="jsbin-javascript"> | |
| const INCREMENT = 'INCREMENT'; | |
| const DECREMENT = 'DECREMENT'; | |
| const increment = (diff) => ({ | |
| type: INCREMENT, | |
| diff: diff | |
| }); | |
| const decrement = (diff) => ({ | |
| type: DECREMENT, | |
| diff: diff | |
| }); | |
| const initialState = { | |
| number: 1, | |
| foo: 'bar', | |
| baz: 'qux' | |
| } | |
| function counter(state = initialState, action) { | |
| switch(action.type) { | |
| case INCREMENT: | |
| return { | |
| ...state, | |
| number: state.number + action.diff | |
| }; | |
| case DECREMENT: | |
| return { | |
| ...state, | |
| number: state.number - action.diff | |
| }; | |
| default: | |
| return state; | |
| } | |
| } | |
| const { createStore } = Redux; | |
| const store = createStore(counter); | |
| cosnt | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">const INCREMENT = 'INCREMENT'; | |
| const DECREMENT = 'DECREMENT'; | |
| const increment = (diff) => ({ | |
| type: INCREMENT, | |
| diff: diff | |
| }); | |
| const decrement = (diff) => ({ | |
| type: DECREMENT, | |
| diff: diff | |
| }); | |
| const initialState = { | |
| number: 1, | |
| foo: 'bar', | |
| baz: 'qux' | |
| } | |
| function counter(state = initialState, action) { | |
| switch(action.type) { | |
| case INCREMENT: | |
| return { | |
| ...state, | |
| number: state.number + action.diff | |
| }; | |
| case DECREMENT: | |
| return { | |
| ...state, | |
| number: state.number - action.diff | |
| }; | |
| default: | |
| return state; | |
| } | |
| } | |
| const { createStore } = Redux; | |
| const store = createStore(counter); | |
| cosnt</script></body> | |
| </html> |
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 INCREMENT = 'INCREMENT'; | |
| const DECREMENT = 'DECREMENT'; | |
| const increment = (diff) => ({ | |
| type: INCREMENT, | |
| diff: diff | |
| }); | |
| const decrement = (diff) => ({ | |
| type: DECREMENT, | |
| diff: diff | |
| }); | |
| const initialState = { | |
| number: 1, | |
| foo: 'bar', | |
| baz: 'qux' | |
| } | |
| function counter(state = initialState, action) { | |
| switch(action.type) { | |
| case INCREMENT: | |
| return { | |
| ...state, | |
| number: state.number + action.diff | |
| }; | |
| case DECREMENT: | |
| return { | |
| ...state, | |
| number: state.number - action.diff | |
| }; | |
| default: | |
| return state; | |
| } | |
| } | |
| const { createStore } = Redux; | |
| const store = createStore(counter); | |
| cosnt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment