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

react-decorators

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-decorators - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

9

lib/properties-transformer.js

@@ -52,9 +52,4 @@ var React = require('react');

}
if (parent === null) {
child.prototype = Object.create(parent);
}
else {
__.prototype = parent.prototype;
child.prototype = new __;
}
__.prototype = parent.prototype;
child.prototype = new __;
return child;

@@ -61,0 +56,0 @@ }

{
"name": "react-decorators",
"version": "1.1.0",
"version": "1.1.1",
"description": "A collection of react decorators to enhance components capabilities",

@@ -9,3 +9,3 @@ "main": "./index.js",

"prepublish": "npm test",
"test": "npx mocha --require ./tests/bootstrap tests/"
"test": "nyc mocha tests/"
},

@@ -19,6 +19,7 @@ "repository": {

"decorators",
"utils",
"classnames",
"css-modules",
"context"
"context",
"inject",
"utils"
],

@@ -30,2 +31,15 @@ "author": "Ido Moshe",

},
"nyc": {
"reporter": [
"text"
],
"require": [
"./tests/bootstrap"
],
"exclude": [
"tests"
],
"sourceMap": false,
"instrument": false
},
"homepage": "https://github.com/iMoses/react-decorators#readme",

@@ -40,2 +54,3 @@ "dependencies": {

"babel-cli": "^6.26.0",
"babel-plugin-istanbul": "^4.1.6",
"babel-plugin-rewire": "^1.1.0",

@@ -48,7 +63,9 @@ "babel-plugin-transform-decorators-legacy": "^1.3.4",

"chai": "^4.1.2",
"coveralls": "^3.0.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"jsdom": "^11.9.0",
"mocha": "^5.1.0"
"mocha": "^5.1.0",
"nyc": "^11.7.1"
}
}

@@ -5,5 +5,10 @@ # React-decorators

Feel free to open a PR with your own decorators. For large
new features, please open an issue first.
[![npm/react-decorators](https://nodei.co/npm/react-decorators.png?compact=true)](https://www.npmjs.org/package/react-decorators)
[![Build Status](https://travis-ci.org/iMoses/react-decorators.svg?branch=master)](https://travis-ci.org/iMoses/react-decorators)
[![Coverage Status](https://coveralls.io/repos/github/iMoses/react-decorators/badge.svg?branch=master)](https://coveralls.io/github/iMoses/react-decorators?branch=master)
Feel free to open a PR with your own decorators.
For large new features, please open an issue first.
## Installation

@@ -13,14 +18,10 @@

```shell
```
npm install --save react-decorators
```
[![npm/react-decorators](https://nodei.co/npm/react-decorators.png?compact=true)](https://www.npmjs.org/package/react-decorators)
## Decorators
## Usage
#### The documentation is under construction
**Everything is pretty much under construction**
## Decorators
- [classNames](#classnames)

@@ -89,3 +90,3 @@ - [cssModules](#cssmodules)

```js
```
@cssModules(require('./my-component.scss'))

@@ -97,12 +98,23 @@ class MyComponent extends React.Component { ... }

**What is does**
The `@injectContext` decorator wraps your component with multiple consumers and maps their values to the base component's `props`.
This decorator receives a map of property names to context consumers,
and injects these the consumers values as properties to the base component.
**Usage:**
```
@injectContext({ propName: Consumer, ... })
class BaseComponent extends React.Component { ... }
```
`injectContext({propName: Consumer[, ...]})`
**Parameters:**
- `consumersMap` - an Object mapping property names to context consumers
**Examples:**
```js
const ThemeContext = React.createContext('default');
const DepthContext = React.createContext(0);
// ...
@injectContext({
theme: ThemeConsumer,
theme: ThemeContext.Consumer,
depth: DepthContext.Consumer,
})

@@ -113,4 +125,5 @@ class MyComponent extends React.Component {

return (
<div className={this.props.theme.container}>
// Content goes here
<div>
<p>Active Theme: {this.props.theme}</p>
<p>Current Depth: {this.props.depth}</p>
</div>

@@ -117,0 +130,0 @@ );

@@ -1,2 +0,2 @@

import propertiesTransformer from '../lib/properties-transformer';
import propertiesTransformer, { __RewireAPI__ } from '../lib/properties-transformer';
import { mount, shallow } from 'enzyme';

@@ -13,2 +13,4 @@ import ReactDOM from 'react-dom';

const EmptyComponent = propertiesTransformer(() => null, () => {});
const StatelessComponent = propertiesTransformer(

@@ -31,2 +33,3 @@ props => <div {...props} />,

</ExternalComponent>
<EmptyComponent />
</StatelessComponent>

@@ -45,2 +48,6 @@ );

it(`validate null elements are treated correctly`, () => {
expect(el.find(EmptyComponent).shallow().type()).to.equal(null);
});
});

@@ -50,4 +57,8 @@

class SubComponent extends React.Component {
static subProp = true;
}
const ClassComponent = propertiesTransformer(
class extends React.Component {
class extends SubComponent {
static staticProp = true;
render() {

@@ -85,2 +96,8 @@ return <div {...this.props} />;

it(`validate inheritance of static properties`, () => {
expect(ClassComponent.staticProp).to.equal(true);
expect(ClassComponent.hasOwnProperty('subProp')).to.equal(false);
expect(ClassComponent.hasOwnProperty('staticProp')).to.equal(true);
});
});

@@ -87,0 +104,0 @@

Sorry, the diff of this file is not supported yet

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