@rebilly/framepay-react
Version:
A React wrapper for Rebilly's FramePay offering out-of-the-box support for Redux and other common React features
24 lines (19 loc) • 738 B
text/typescript
import * as React from 'react';
import { REACT_VERSION } from './constants';
import getFramepayApi from './get-framepay-api';
import type { FramePayContext } from '../../types/context';
const defaultContextValue = {
api: getFramepayApi(),
error: null,
ready: false,
};
let ProvidedContext;
if (/^15.*/.test(REACT_VERSION) || /^0.14.*/.test(REACT_VERSION)) {
const createReactContext = require('create-react-context');
ProvidedContext = createReactContext(defaultContextValue);
} else {
ProvidedContext = React.createContext<FramePayContext>(defaultContextValue);
}
const ContextProvider = ProvidedContext.Provider;
const ContextConsumer = ProvidedContext.Consumer;
export { ContextProvider, ContextConsumer };