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

react-hot-loader

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hot-loader - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

replaceCreateClass.js

4

example/a.jsx
/** @jsx React.DOM */
var React = require('react'),
B = require('react-hot?B!./b');
B = require('react-hot!./b');

@@ -16,3 +16,3 @@ var A = React.createClass({

<div>
<p>Open this editor, edit and save <code>example/a.jsx</code>.</p>
<p>Open an editor, edit and save <code>example/a.jsx</code>.</p>
<p><b>The number should not change.</b></p>

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

/** @jsx React.DOM */
var React = require('react'),
A = require('react-hot?A!./a');
A = require('react-hot!./a');
React.renderComponent(<A />, document.body);

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

module.exports = function() {};
module.exports = function () {};
module.exports.pitch = function (remainingRequest) {

@@ -9,34 +9,15 @@ this.cacheable && this.cacheable();

'var HotUpdateMixin = require(' + JSON.stringify(require.resolve('./makeHotUpdateMixin')) + ')();',
'var React = require("react");',
'function runWithMonkeyPatchedReact(f) {',
' var realCreateClass = React.createClass;',
' var injected = 0;',
' React.createClass = function createHotUpdateClass(spec) {',
' if (spec.displayName === ' + JSON.stringify(displayName) + ') {',
' if (!spec.mixins) spec.mixins = [];',
' spec.mixins.push(HotUpdateMixin.Mixin);',
' injected++;',
' }',
' return realCreateClass(spec);',
' };',
' f();',
' if (injected === 0) {',
' console.warn(\'Could not find component with displayName: ' + JSON.stringify(displayName) + '\');',
' } else if (injected > 1) {',
' console.warn(\'Found more than one component with displayName: ' + JSON.stringify(displayName) + '\');',
' }',
' React.createClass = realCreateClass;',
'}',
'runWithMonkeyPatchedReact(function () {',
' module.exports = require(' + JSON.stringify(moduleRequest) + ');',
'});',
'function createHotClass(spec) {',
' if (!spec.mixins) spec.mixins = [];',
' spec.mixins.push(HotUpdateMixin.Mixin);',
' return require("react").createClass(spec);',
'};',
'if (module.hot) {',
' module.hot.accept(' + JSON.stringify(moduleRequest) + ', function() {',
' runWithMonkeyPatchedReact(function () {',
' module.exports = require(' + JSON.stringify(moduleRequest) + ');',
' });',
' module.hot.accept(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ', function() {',
' module.exports = require(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ')(createHotClass);',
' HotUpdateMixin.acceptUpdate(module.exports);',
' });',
'}'
'}',
'module.exports = require(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ')(createHotClass);'
].join('\n');
};
{
"name": "react-hot-loader",
"version": "0.1.0",
"version": "0.1.2",
"description": "Webpack loader that enables live-editing React components without unmounting or losing their state",

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

@@ -20,6 +20,2 @@ # react-hot-loader

### Limitations
* You have to include component's displayName in `require` call
### Implementation Notes

@@ -30,2 +26,5 @@

>The problem is that references to component descriptors could be stored in any number of places. What we could do is wrap all components in "proxy" components which look up the "real" component in some mapping
## Installation

@@ -40,4 +39,3 @@

```javascript
// Currently you have to pass displayName to require call:
var Button = require('react-hot?Button!./button');
var Button = require('react-hot!./button');
```

@@ -44,0 +42,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