next
Version:
The React Framework
39 lines (37 loc) • 1.62 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "shouldHardNavigate", {
enumerable: true,
get: function() {
return shouldHardNavigate;
}
});
const _flightdatahelpers = require("../../flight-data-helpers");
const _matchsegments = require("../match-segments");
function shouldHardNavigate(flightSegmentPath, flightRouterState) {
const [segment, parallelRoutes] = flightRouterState;
// TODO-APP: Check if `as` can be replaced.
const [currentSegment, parallelRouteKey] = flightSegmentPath;
// Check if current segment matches the existing segment.
if (!(0, _matchsegments.matchSegment)(currentSegment, segment)) {
// If dynamic parameter in tree doesn't match up with segment path a hard navigation is triggered.
if (Array.isArray(currentSegment)) {
return true;
}
// If the existing segment did not match soft navigation is triggered.
return false;
}
const lastSegment = flightSegmentPath.length <= 2;
if (lastSegment) {
return false;
}
return shouldHardNavigate((0, _flightdatahelpers.getNextFlightSegmentPath)(flightSegmentPath), parallelRoutes[parallelRouteKey]);
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=should-hard-navigate.js.map
;