import * as React from 'react'; import { Store } from 'redux'; import { Effect, FxState, FxSlice, FxActionCreators, FxActionsConfig } from 'fx-state'; import { Renderable, Omit } from './types'; declare type DeclarativeEffectChildren = (state: FxState) => Renderable; export interface DeclarativeEffectProps { effect: Effect | FxActionsConfig; params: Params; children: DeclarativeEffectChildren; store?: Store; } /** * DeclarativeEffect is a React render-prop component that injects FxState for any side effect into its children. * It executes the given side-effect on mount and when the given `params` change. * This can be used to render the results of a query, such as search results or a specific record. * Each instance of a DeclarativeEffect will own its own unique FxState and FxActions. * On unmount, the component will destroy its FxState, cleaning up after itself. * * The following example initiates the given side effect when the component mounts. * While it is pending, it renders a loading indicator. * When it resolves, it renders the value that was passed to `resolve()`. * If the Promise is rejected, it renders the error that was passed to `reject()`. * * @example * ``` * // typeof effect: (p1: number, p2: string) => Promise * * * {state => *
* {state.error ? {state.error} * : state.data ? {state.data} : state.status === 'active' && } *
} *
* ``` */ export declare class DeclarativeEffect extends React.Component> { fxActions: FxActionCreators; constructor(props: DeclarativeEffectProps); render(): JSX.Element; } /** * ContextDeclarativeEffect is identical to DeclarativeEffect, except that it uses StoreConsumer to pull the `store` prop off of Legacy React Context. */ export declare class ContextDeclarativeEffect extends React.Component, 'store'>> { render(): JSX.Element; } export {};