0.0.4 • Published 2 years ago

@universal-di/react v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Universal Dependency Injection port for React

MIT License Build Status NPM version Coverage Status PRs welcome

Pre-requisites

Contents

DIContextProvider

DIContextProvider is a React context provider that allows you to provide dependencies to your React DOM.

const application = new DIApplication(AppModule);

<DIContextProvider
    injector={application.rootInjector}
>
    <ProductListComponent />
</DIContextProvider>

useInjection

useInjection is a hook that allows you to inject dependencies into your React components.

export function ProductListComponent() {
    // AnalyticsService type is inferred here
    const analyticsService = useInjection(ANALYTICS_SERVICE);

    useEffect(() => {
        analyticsService.track('browsed-productes');
    }, []);
}

Authors

szymeo bartoszswitalski

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago