on 8d566ea help sign in
bridge/src/store/hosting.js
23 lines 633 B history raw
1import React, { createContext, useContext, forwardRef } from 'react';
3import useHostingStore from './lib/useHostingStore';
5export const HostingContext = createContext(null);
7export function HostingProvider({ children }) {
8 const store = useHostingStore('');
9 return (
10 <HostingContext.Provider value={store}>{children}</HostingContext.Provider>
11 );
14export function useHosting() {
15 return useContext(HostingContext);
18export const withHosting = Component =>
19 forwardRef((props, ref) => (
20 <HostingContext.Consumer>
21 {store => <Component ref={ref} {...store} {...props} />}
22 </HostingContext.Consumer>
23 ));