New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-hoc-context

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hoc-context

Dependency-inject a module using react higher-order components (HOCs)

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

react-hoc-context

Wrap your component in withModule to have props.module injected into your components.

Objects in the module may persist outside the component scope.

Avoids needless piping of objects through the props of components.

You may pass in additional modules into withModule to have the lifecycle of the given modules bound to the component.

props.module is a composite of all added modules.

Import looks like:

import withModule from "react-hoc-di/withModule";

Usage often looks like this:

export default withModule(MyScreen, MyModule);

or

export default withModule(MyComponent);

or

export default withModule(MyComponent, [MyModule1, MyModule2]);

Modules

Modules always define a construct and destruct function.

Note construct is not the same as constructor.

The shell of a module looks like this:

class MyModule {
  constructor(rootModule) {
    this.rootModule = rootModule;
  }

  construct() {
  // Set objects onto root module.
  }

  destruct() {
    // Remove those objects from root module.
  }
}

export default MyModule;

For Developer

Remember to npm run build before deploying.

Keywords

react

FAQs

Package last updated on 04 Sep 2021

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