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
| function updateState(dispatch) { | |
| // helper functions | |
| const dispatchError = e => | |
| dispatch(SET_STATUS({ status: 'error', message: e.message })); | |
| dispatch(SET_STATUS({ status: 'submitting' })); | |
| return fetch('https://example.com/api/a') | |
| .then(() => { | |
| dispatch(SET_STATUS({ status: 'processing' })); |
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
| function updateState(dispatch) { | |
| const dispatchStatus = status => dispatch(SET_STATUS({ status })); | |
| const dispatchError = e => | |
| dispatch(SET_STATUS({ status: 'error', message: e.message })); | |
| dispatchStatus('submitting'); | |
| return fetch('https://example.com/api/a') | |
| .then(() => { | |
| dispatchStatus('processing'); |
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 getResponseJson = async response => response.json(); | |
| function updateState(dispatch) { | |
| const dispatchStatus = status => dispatch(SET_STATUS({ status })); | |
| const dispatchError = e => | |
| dispatch(SET_STATUS({ status: 'error', message: e.message })); | |
| const dispatchState = data => dispatch(SET_STATE({ data })); | |
| dispatchStatus('submitting'); |
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 getResponseJson = async response => response.json(); | |
| function updateState(dispatch) { | |
| const dispatchStatus = status => dispatch(SET_STATUS({ status })); | |
| const dispatchError = e => | |
| dispatch(SET_STATUS({ status: 'error', message: e.message })); | |
| const dispatchState = data => dispatch(SET_STATE({ data })); | |
| dispatchStatus('submitting'); |
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 setStatus = (status, message) => SET_STATUS({ status, message }); | |
| const getResponseJson = async response => response.json(); | |
| const fetchUrl = url => () => fetch(url); | |
| function updateState(dispatch) { | |
| const dispatchStatus = status => () => dispatch(setStatus(status)); | |
| const dispatchError = ({ message }) => dispatch(setStatus('error', message)); | |
| const dispatchState = data => dispatch(SET_STATE({ data })); | |
| dispatchStatus('submitting')(); |
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 setStatus = (status, message) => SET_STATUS({ status, message }); | |
| const getResponseJson = async response => response.json(); | |
| const fetchUrl = url => () => fetch(url); | |
| function updateState(dispatch) { | |
| const dispatchStatus = status => () => dispatch(setStatus(status)); | |
| const dispatchError = ({ message }) => dispatch(setStatus('error', message)); | |
| const dispatchState = data => dispatch(SET_STATE({ data })); | |
| return Promise.resolve() |
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
| for (let i = 0; i < array.length; i++) { | |
| const el = array[i]; | |
| // do something here | |
| } |
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
| Array.prototype.forEach(el => { | |
| // do something here | |
| }); |
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
| for (const el of array) { | |
| // do something here | |
| } |
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
| .Modal { | |
| /* fixed position will always show modal in the top left corner */ | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| /* z-index to show modal even if it is used before some other elements */ | |
| z-index: 5; | |
| /* make modal fill whole window */ | |
| width: 100vw; | |
| height: 100vh; |