1 import React from 'react';
3 const UserContext = React.createContext(null);
5 export const useUser = () => React.useContext(UserContext);
7 export const withUser = (WrappedComponent, as) => function WithUserContext(props) {
8 return <UserContext.Consumer>
9 {user => <WrappedComponent {...{[as || 'user']: user, ...props}} />}
10 </UserContext.Consumer>;
13 export default UserContext;