Skip to main content

UseInjector

useInjector

Exposes the Angular injector which allows the injection of services into React components.

Example

import { useInjector } from '@vendure/admin-ui/react';
import { NotificationService } from '@vendure/admin-ui/core';

export const MyComponent = () => {
const notificationService = useInjector(NotificationService);

const handleClick = () => {
notificationService.success('Hello world!');
};
// ...
return <div>...</div>;
}
Signature
function useInjector<T = any>(token: ProviderToken<T>): T

Parameters

token

parameter
ProviderToken<T>