SHARE
TWEET

Untitled

a guest Jul 16th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useContext } from 'react';
  2. import { usePersistState } from 'hooks/usePersistState';
  3.  
  4. const Context = React.createContext('default');
  5.  
  6. const Theme = ({ theme, children }) => {
  7.   const [_theme, setTheme] = usePersistState({ key: 'theme', defaultValue: theme });
  8.  
  9.   return (
  10.     <Context.Provider value={{ theme: _theme, setTheme }}>
  11.       {children}
  12.     </Context.Provider>
  13.   )
  14. };
  15.  
  16. export const withTheme = (Component) =>
  17.   (props) => (<Component {...props} {...useContext(Context)} />);
  18.  
  19. export default Theme;
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
 
Top