Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-magnetic-di

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-magnetic-di - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

2

lib/cjs/eslint/rules/sort-dependencies.js

@@ -18,3 +18,3 @@ "use strict";

messages: {
unsortedInjectable: 'Expected dependencie names to be sorted. ' + "'{{name}}' should be before '{{prevName}}'."
unsortedInjectable: 'Expected dependencies to be ordered by name. ' + "'{{name}}' should be before '{{prevName}}'."
}

@@ -21,0 +21,0 @@ },

@@ -16,3 +16,3 @@ var _require = require('../utils'),

messages: {
unsortedInjectable: 'Expected dependencie names to be sorted. ' + "'{{name}}' should be before '{{prevName}}'."
unsortedInjectable: 'Expected dependencies to be ordered by name. ' + "'{{name}}' should be before '{{prevName}}'."
}

@@ -19,0 +19,0 @@ },

{
"name": "react-magnetic-di",
"version": "2.2.0",
"version": "2.2.1",
"description": "Context driven dependency injection",

@@ -5,0 +5,0 @@ "keywords": [

@@ -192,3 +192,23 @@ <p align="center">

- Does not support dynamic `use` and `target` props (changes are ignored)
- Officially supports injecting only functions/classes. If you need to inject some other data types, create a simple getter and use that as dependency.
- Does not replace default props (or default parameters in general): so dependencies provided as default parameters (eg `function MyComponent ({ modal = Modal }) { ... }`) will be ignored. If you accept the dependency as prop/argument you should inject it via prop/argument, as having a double injection strategy is just confusing.
## Can it be used without Babel plugin?
Yes, but you will have to handle variable assignment yourself, which is a bit verbose. In this mode `di` needs an array of dependencies as first argument and the component, or `null`, as second (to make `target` behaviour work). Moreover, `di` won't be removed on prod builds and ESLint rules are not currently compatible with this mode.
```js
import React, { Component } from 'react';
import { di } from 'react-magnetic-di';
import { Modal as ModalInj } from 'material-ui';
import { useQuery as useQueryInj } from 'react-apollo';
function MyComponent() {
const [Modal, useQuery] = di([ModalInj, useQueryInj], MyComponent);
const { data } = useQuery();
return <Modal>{data && 'Done!'}</Modal>;
}
```
## Contributing

@@ -195,0 +215,0 @@

@@ -27,2 +27,8 @@ declare module 'react-magnetic-di' {

function di(...dependencies: Dependency[]): void;
/** allow using di without Babel */
function di<T extends Dependency>(
dependencies: T[],
self: ComponentType<any> | null
): T[];
class di {

@@ -29,0 +35,0 @@ /** @deprecated use injectable instead */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc