Skip to content

Instantly share code, notes, and snippets.

@jasonleehodges
Last active March 21, 2020 22:39
Show Gist options
  • Save jasonleehodges/0b0d4b462574fdca85993e5de4c2ed04 to your computer and use it in GitHub Desktop.
Save jasonleehodges/0b0d4b462574fdca85993e5de4c2ed04 to your computer and use it in GitHub Desktop.
Example of dispatching data with a singleton store (anti-pattern)
// 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