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

react-jss

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-jss - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

42

lib/index.js

@@ -17,5 +17,5 @@ 'use strict';

var _jss = require('jss');
var _jss2 = require('jss');
var _jss2 = _interopRequireDefault(_jss);
var _jss3 = _interopRequireDefault(_jss2);

@@ -30,7 +30,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function decorate(DecoratedComponent, rules) {
function decorate(_jss, DecoratedComponent, rules, options) {
var _class, _temp;
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var refs = 0;

@@ -40,3 +38,3 @@ var sheet = null;

function attach() {
if (!sheet) sheet = (options.jss || _jss2.default).createStyleSheet(rules, options);
if (!sheet) sheet = _jss.createStyleSheet(rules, options);
sheet.attach();

@@ -80,3 +78,3 @@ }

if (process.env.NODE_ENV !== 'production') {
// Support React Hot Loader
// Support React Hot Loader.
if (this.sheet !== sheet) {

@@ -105,26 +103,20 @@ this.sheet.detach();

function useSheet(rulesOrComponentOrJss) {
var _arguments = arguments;
if (rulesOrComponentOrJss instanceof _jss2.default.constructor) {
return function (component) {
var rules = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
if (typeof component != 'function') {
rules = component;
options = rules;
}
options.jss = rulesOrComponentOrJss;
return useSheet(component, rules, options);
};
function useSheet(_jss, DecoratedComponent, rules, options) {
// User didn't pass an own jss instance, lets use the global one.
if (!(_jss instanceof _jss3.default.constructor)) {
return useSheet.bind(null, _jss3.default);
}
if (typeof rulesOrComponentOrJss === 'function') {
// Manually called by user: `useSheet(DecoratedComponent, rules, options)`
if (typeof DecoratedComponent === 'function') {
return decorate.apply(undefined, arguments);
}
return function (DecoratedComponent) {
return decorate.apply(undefined, [DecoratedComponent].concat(Array.prototype.slice.call(_arguments)));
// Used a decorator: `useSheet(rules, options)(DecoratedComponent)`
rules = DecoratedComponent;
options = rules;
return function (_DecoratedComponent) {
return decorate(_jss, _DecoratedComponent, rules, options);
};
}
{
"name": "react-jss",
"version": "2.0.2",
"version": "2.0.3",
"description": "JSS mixin for React components",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

## React JSS
This modules does ref counting and detaches [JSS](https://github.com/jsstyles/jss) style sheets when all components using them are unmounted. You need this module only if you build a big application where leaving all styles in the DOM might have performance impact or you are going to hit [IE limits](http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164546.aspx).
The benefit of using react-jss instead of using [JSS](https://github.com/jsstyles/jss) directly is lazy evaluation and auto mount/unmount. It will compile your styles to CSS only when a component using them is mounted for the first time. Through ref counting, it will unmount styles when they are not in use by any of mounted component.
You need this module if you build a big application where leaving all styles in the DOM or compiling all styles at once might have performance impact or you are going to hit [IE limits](http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164546.aspx).
### Usage

@@ -6,0 +8,0 @@

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