@transact-open-ux/react
Version:
Library to integrate React with Transact Open UX
34 lines (33 loc) • 1.32 kB
TypeScript
import React from "react";
import { TransactProviderState } from "../providers/TransactProvider";
export interface WithTransactProps {
/**
* Contains all of the <TransactConsumer /> props wrapped conveniently in a HOC under the transact prop
*/
transact?: TransactProviderState;
}
/**
* `withTransact()` is a higher-order component (HoC) that allows you to hook into the TransactProvider components context.
*
* It is used internally to construct the `PageProvider` and `TransactForm` components, however you can use it to build out new components as your needs change.
*
* This component must be within the TransactProvider component.
* ## Example
* ```jsx
* import React from 'react';
* import { withTransact } from '@transact-open-ux/react';
*
* const SaveButton = props => {
* // All TransactProps available on props.transact
* return (
* <button type="button" onClick={() => props.transact.userSave(props.getFormApi().values)}>
* Click To Save Application
* </button>
* )
* };
*
* export default withTransact(SaveButton);
* ```
*/
declare const withTransact: <OriginalProps extends {}>(WrappedComponent: React.ComponentType<OriginalProps & WithTransactProps>) => (props: OriginalProps) => JSX.Element;
export default withTransact;