You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@ogre-tools/injectable-react

Package Overview
Dependencies
Maintainers
2
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ogre-tools/injectable-react

A brutal component for injecting components that use injectable

17.11.1
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

Dependency injection for React in Ogre Tools

A brutal component for injecting components that use injectable.

Usage

$ npm install @ogre-tools/injectable
$ npm install @ogre-tools/injectable-react
...

import { withInjectables } from '@ogre-tools/injectable-react';

Usage

it('given a Component is registered, when Inject is rendered for the Component, renders with dependencies', () => {
  const di = createContainer();


  const NonInjectedTestComponent = ({ someDependency, ...props }) => (
    <div {...props}>Some content: "{someDependency}"</div>
  );

  const TestComponent = withInjectables(NonInjectedTestComponent, {
    getProps: (di, props) => ({
      someDependency: 'some-value',
      ...props,
    }),
  });

  const actual = mount(
    <DiContextProvider value={{ di }}>
      <TestComponent some-prop="some-other-prop" />
    </DiContextProvider>,
  );

  expect(actual).toHaveText('Some content: "some-value"');
});

Documentation

Check unit tests for documentation.

Keywords

js

FAQs

Package last updated on 29 Nov 2023

Did you know?

Socket

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.

Install

Related posts