Function DependencyContainer

  • Provides a new dependency container to React app

    This component creates a new container and provides it down to React children.

    If binder callback is specified, it will be called for a new container to binds it with dependencies.

    If a parent container is exist, it is connected to the current one by default. For making a new root container specify root parameter as true, and the container will not depend on any parent container.

    Example

    const TOKEN = token();

    function appDependencyBinder(container: Container) {
    container.bindValue(TOKEN, 'value');
    }

    function App() {
    return (
    <DependencyContainer root binder={appDependencyBinder}>
    <NestedComponent />
    </DependencyContainer>
    );
    }

    Parameters

    Returns ReactElement

Generated using TypeDoc