Dmitriy Pleshevskiy
49aac94675
chore: add dist folder to repo chore(deps): add node-fetch for tests chore: change prepare request visibility chore: add tests for prepare request method chore: update example Closes #20
11 lines
499 B
JavaScript
11 lines
499 B
JavaScript
import React from 'react';
|
|
import invariant from 'tiny-invariant';
|
|
const RequestContext = React.createContext(null);
|
|
export function RequestProvider({ client, defaultHeaders, children }) {
|
|
return (React.createElement(RequestContext.Provider, { value: { client, defaultHeaders } }, children));
|
|
}
|
|
export function useRequestContext() {
|
|
const context = React.useContext(RequestContext);
|
|
invariant(context, 'useRequestContext() must be a child of <RequestProvider />');
|
|
return context;
|
|
}
|