Skip to content

Commit

Permalink
Fix issue #28 by unmounting route target before mounting a new one.
Browse files Browse the repository at this point in the history
  • Loading branch information
dicky authored and dicky committed Jun 16, 2017
1 parent f315ac9 commit 706dc9c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion WebApplication.Core.React/wwwroot/lib/dotnetify-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify;
});

dotnetify.react = $.extend(dotnetify.hasOwnProperty("react") ? dotnetify.react : {}, {
version: "1.0.2-beta",
version: "1.0.3-beta",
viewModels: {},
plugins: {},

Expand Down Expand Up @@ -398,6 +398,13 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify;
return;
}

try {
_ReactDOM.unmountComponentAtNode(document.querySelector(iTargetSelector));
}
catch (e) {
console.error(e);
}

try {
var reactElement = _React.createElement(window[iReactClassName], iReactProps);
_ReactDOM.render(reactElement, document.querySelector(iTargetSelector));
Expand Down
9 changes: 8 additions & 1 deletion dist/dotnetify-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify;
});

dotnetify.react = $.extend(dotnetify.hasOwnProperty("react") ? dotnetify.react : {}, {
version: "1.0.2-beta",
version: "1.0.3-beta",
viewModels: {},
plugins: {},

Expand Down Expand Up @@ -398,6 +398,13 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify;
return;
}

try {
_ReactDOM.unmountComponentAtNode(document.querySelector(iTargetSelector));
}
catch (e) {
console.error(e);
}

try {
var reactElement = _React.createElement(window[iReactClassName], iReactProps);
_ReactDOM.render(reactElement, document.querySelector(iTargetSelector));
Expand Down
Loading

0 comments on commit 706dc9c

Please sign in to comment.