-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
223 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"node": true, | ||
"globals": { | ||
"window": true, | ||
"Notification": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Provides `createClass` and `updateClass` which can be used as drop-in | ||
* replacement for `React.createClass` in a module. If multiple components | ||
* are defined in the same module, assumes their `displayName`s are different. | ||
*/ | ||
module.exports = function (filename, React) { | ||
var componentUpdaters = {}; | ||
|
||
function createClass(spec) { | ||
var displayName = spec.displayName, | ||
componentUpdater; | ||
|
||
if (componentUpdaters[displayName]) { | ||
throw new Error( | ||
'Found duplicate displayName in ' + filename + ': "' + displayName + '".\n' + | ||
'react-hot-loader uses displayName to distinguish between several components in one file.' | ||
); | ||
} | ||
|
||
componentUpdater = require('./makeComponentUpdater')(React); | ||
componentUpdaters[displayName] = componentUpdater; | ||
|
||
return componentUpdater.createClass(spec); | ||
} | ||
|
||
function updateClass(spec) { | ||
var displayName = spec.displayName, | ||
componentUpdater = componentUpdaters[displayName]; | ||
|
||
return componentUpdater ? | ||
componentUpdater.updateClass(spec) : | ||
createClass(spec); | ||
} | ||
|
||
function updateMountedInstances() { | ||
Object.keys(componentUpdaters).forEach(function (displayName) { | ||
componentUpdaters[displayName].updateMountedInstances(); | ||
}); | ||
} | ||
|
||
function canUpdateModule() { | ||
return Object.keys(componentUpdaters).length > 0; | ||
} | ||
|
||
return { | ||
createClass: createClass, | ||
updateClass: updateClass, | ||
updateMountedInstances: updateMountedInstances, | ||
canUpdateModule: canUpdateModule | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.