Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
brandi-react
Advanced tools
Brandi-React is the React bindings layer for Brandi — the dependency injection container. It lets your React components get dependencies from Brandi containers.
Brandi-React requires React 16.8 or later. You'll also need to install Brandi.
# NPM
npm install brandi-react
# Yarn
yarn add brandi-react
The Brandi-React source code is written in TypeScript but we precompile both CommonJS and ESModule builds to ES2018.
Additionally, we provide builds precompiled to ESNext by esnext
, esnext:main
and esnext:module
fields.
TypeScript type definitions are included in the library and do not need to be installed additionally.
ContainerProvider
—
makes the Brandi container available to any nested components that need to use injections.useInjection(token)
—
allows you to get a dependency from a container.createInjectionHooks(...tokens)
—
creates hooks for getting dependencies more easily.tagged(...tags)(Component, [options])
—
attaches tags to the component and all nested components.You can find the full Brandi documentation on the website.
// index.ts
import { createContainer } from 'brandi';
import { ContainerProvider } from 'brandi-react';
import React from 'react';
import ReactDOM from 'react-dom';
import { TOKENS } from './tokens';
import { ApiService } from './ApiService';
import { App } from './App';
const container = createContainer();
container.bind(TOKENS.apiService).toInstance(ApiService).inTransientScope();
ReactDOM.render(
<ContainerProvider container={container}>
<App />
</ContainerProvider>,
document.getElementById('root'),
);
// UserComponent.tsx
import { useInjection } from 'brandi-react';
import { FunctionComponent } from 'react';
import { TOKENS } from './tokens';
export const UserComponent: FunctionComponent = () => {
const apiService = useInjection(TOKENS.apiService);
/* ... */
return (/* ... */);
}
FAQs
React bindings for Brandi — the dependency injection container.
The npm package brandi-react receives a total of 393 weekly downloads. As such, brandi-react popularity was classified as not popular.
We found that brandi-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.