@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
15 lines • 1.55 kB
JavaScript
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{ACTION_REPLACE}from'@virtuous/conductor';import{navigate}from"../../action-creators/router";import{mutable}from"../../helpers/redux";/**
* @mixes {MutableFunction}
* @param {Object} params The history params.
* @param {Object} [options={}] Additional options for the action
* @param {boolean} [options.remountRoute=true] When set to "true", the target route will be forced
* to remount.
* @return {Function} The dispatched action.
*/export var historyReplace=mutable(function(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){dispatch(navigate(_extends({},params,{},(options===null||options===void 0?void 0:options.remountRoute)!==false&&{state:_extends({},params.state,{/**
* When a route is "replaced" the router doesn't assign a new route id to the old route
* stack entry. This can cause issues when a route is replaced by itself, since the content
* will not remount out of the box.
*
* When the "replaceRouteId" state prop is injected, the Route component performs logic
* to enforce re-remounting routes which where replaced by itself.
*/replaceRouteId:Math.random().toString(36).substring(2,7)})},{action:ACTION_REPLACE})));};});