Last active
March 21, 2020 22:39
-
-
Save jasonleehodges/0b0d4b462574fdca85993e5de4c2ed04 to your computer and use it in GitHub Desktop.
Example of dispatching data with a singleton store (anti-pattern)
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
// typically this lives where the provider wraps the root component | |
import { store } from './location-of-instantiated-store'; | |
import { setData } from '../actions'; | |
export const getDataWithSingletonStore = () => { | |
fetch(url) | |
.then(resp => resp.json()) | |
.then(data => store.dispatch(setData(data))); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment