SHARE
TWEET

Untitled

a guest Jul 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useContext, createContext, useReducer } from 'react';
  2.  
  3. import reducers from './reducers';
  4.  
  5. const StoreContext = createContext();
  6.  
  7. const StoreProvider = ({ children }) => (
  8.     <StoreContext.Provider value={reducers}>
  9.         { children }
  10.     </StoreContext.Provider>
  11. );
  12.  
  13. const useReducerSelector = name =>
  14.     useReducer(
  15.         ...useContext(StoreContext)[name]
  16.     );
  17.  
  18. export {
  19.     StoreProvider,
  20.     useReducerSelector
  21. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top