@shopify/app-bridge-host
Version:
App Bridge Host contains middleware and components that are meant to be consumed by the app's host. The middleware and `Frame` component are responsible for facilitating messages posted between the client and host, and used to act on actions sent from the
35 lines (34 loc) • 1.34 kB
TypeScript
import React from 'react';
import { Reducer, ActionCreatorsMapObject } from 'redux';
import { ComponentProps } from './types';
import { Store } from './store/async';
/**
* The interface for a dynamic feature
* @public
* */
export interface Feature<LocalStore, LocalActions> {
/** actions for the feature*/
actions: LocalActions;
/** the key matching the property name in the store*/
key: keyof Store;
/** the reducer for the feature*/
reducer: Reducer<LocalStore>;
/** optional initial state for the feature*/
initialState?: LocalStore;
}
/**
* The interface the props of a component with a feature
* @public
* */
export interface FeatureProps<LocalStore, LocalActions> extends ComponentProps {
/** actions for the feature*/
actions: LocalActions;
/** the local store for the feature*/
store: LocalStore;
}
/**
* A higher order component that takes a feature and make its actions and reducer available
* @public
* @returns a component which has access to the feature actions and local state
*/
export default function withFeature<LocalStore, LocalActions extends ActionCreatorsMapObject>(feature: Feature<LocalStore, LocalActions>): <OwnProps>(WrappedComponent: React.ComponentType<OwnProps>) => React.ComponentType<OwnProps & ComponentProps & FeatureProps<LocalActions, LocalStore>>;