aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/index.umd.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts
index 9703c6fc0..518326e21 100644
--- a/packages/instant/src/index.umd.ts
+++ b/packages/instant/src/index.umd.ts
@@ -53,14 +53,19 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
injectedDiv.setAttribute('id', INJECTED_DIV_ID);
injectedDiv.setAttribute('class', INJECTED_DIV_CLASS);
appendTo.appendChild(injectedDiv);
- const removeFromDom = () => appendTo.removeChild(injectedDiv);
+ const closeInstant = () => {
+ if (config.onClose) {
+ config.onClose();
+ }
+ appendTo.removeChild(injectedDiv);
+ };
const instantOverlayProps = {
...config,
// If we are using the history API, just go back to close
- onClose: () => (config.shouldDisablePushToHistory ? removeFromDom() : window.history.back()),
+ onClose: () => (config.shouldDisablePushToHistory ? closeInstant() : window.history.back()),
};
ReactDOM.render(React.createElement(ZeroExInstantOverlay, instantOverlayProps), injectedDiv);
- return removeFromDom;
+ return closeInstant;
};
if (config.shouldDisablePushToHistory) {
renderInstant();
@@ -83,9 +88,6 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
} else {
// User pressed back, so close instant.
removeInstant();
- if (!_.isUndefined(config.onClose)) {
- config.onClose();
- }
}
};
}