Skip to content

Commit

Permalink
Merge pull request #3 from vagusX/feature/react-loader
Browse files Browse the repository at this point in the history
fix: fix custom element already exist issue
  • Loading branch information
yuluyi committed May 9, 2017
2 parents ca5a78b + acb7911 commit bf8c8e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions react/componentGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ module.exports = function(tagName, url) {
static displayName = tagName

componentDidMount() {
this.componentWillReceiveProps(this.props)
htmlModuleLoader(url, () => {
const elementConstructor = document.createElement(tagName).constructor
if (elementConstructor === HTMLElement) {
htmlModuleLoader(url, () => {
this.componentWillReceiveProps(this.props)
}, function(e) {
console.err('Load html module failed:', e)
})
} else {
this.componentWillReceiveProps(this.props)
}, function(e) {
console.err('Load html module failed:', e)
})
}
}

componentWillReceiveProps(props) {
Expand Down

0 comments on commit bf8c8e9

Please sign in to comment.