Skip to content

Function: SubContainerProvider()

ts
function SubContainerProvider(props: SubContainerProviderProps): FunctionComponentElement<ProviderProps<Optional<Container>>>;

Defined in: src/wirestate-react/provision/sub-container-provider.ts:109

Provides a managed child container under the nearest parent container.

Parameters

ParameterTypeDescription
propsSubContainerProviderPropsProvider props.

Returns

FunctionComponentElement<ProviderProps<Optional<Container>>>

A React context provider for the child container.

Remarks

Use it for subtree-local services: a checkout flow, modal, wizard step, or tenant branch. The child inherits parent bindings but owns its buses, seeds, lifecycle, and disposal.

Example

tsx
import { Injectable } from "@wirestate/core";
import { SubContainerProvider } from "@wirestate/react";

@Injectable()
class CheckoutService {}

export function CheckoutScope() {
  return (
    <SubContainerProvider entries={[CheckoutService]}>
      <Checkout />
    </SubContainerProvider>
  );
}