connectIModelConnectionAndViewState FunctionConst

Beta  

Function that will connect a component to the IModelConnection data in the Redux store

connectIModelConnectionAndViewState(mapStateToProps?: any, mapDispatchToProps?: any): (component: C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>) => ConnectedComponent<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>, Omit<GetProps<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>, > & TNeedsProps>

example
// connect component for both getting and setting ImodelConnection data from Redux store. import { connectIModelConnection, sessionStateMapDispatchToProps, SessionStateActionsProps } from "@bentley/ui-framework";

export interface ComponentProps extends SessionStateActionsProps { myData: string; }

export const ConnectControl = connectIModelConnection(null, sessionStateMapDispatchToProps)(ComponentClass); // tslint:disable-line:variable-name

// this then allows connected control to update the store using a call like shown below. this.props.setNumItemsSelected(30);

Parameter Type Description
mapStateToProps any optional user function that, if defined, will be executed to provide additional properties from store.
mapDispatchToProps any data passed to Redux connect function.

Returns - (component: C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>) => ConnectedComponent<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>, Omit<GetProps<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>, > & TNeedsProps>

Defined in

Last Updated: 13 June, 2024