Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function mockNavigator(parentKey?: string = 'foo') {
// The constructor is checked in prop-types,
// so we use it as base and then mutate
const navigator = new StateNavigator(
[
{ key: 'foo', route: 'foo' },
{ key: 'bar', route: 'bar' },
{ key: 'barChild', route: 'bar/child', parentKey: 'bar' },
],
new HTML5HistoryManager(),
);
navigator.navigate(parentKey);
return navigator;
}
export default () => {
const stateNavigator = new StateNavigator(
routes(),
new HTML5HistoryManager((process.env.URL_BASENAME || '').slice(0, -1)),
);
handleContactUsHash(stateNavigator);
stateNavigator.onNavigate((oldState, state) => {
const page = routeDefinitions.find(obj => obj.key === state.key);
if (typeof document !== 'undefined') {
const metaDescription = page.description || '';
const tag = document.getElementsByName('description')[0];
if (tag) tag.setAttribute('content', metaDescription);
}
});
return stateNavigator;
};
export default function() {
return new StateNavigator([
{key: 'people', route: '{pageNumber?}', defaults: {pageNumber: 1}},
{key: 'person', route: 'person/{id}', defaults: {id: 0}, trackCrumbTrail: true}
], new HTML5HistoryManager());
};
function getStateNavigator() {
var stateNavigator = new StateNavigator([
{key: 'people', route: '{pageNumber?}', defaults: {pageNumber: 1}},
{key: 'person', route: 'person/{id}', defaults: {id: 0}, trackCrumbTrail: true}
], new HTML5HistoryManager());
var { people, person } = stateNavigator.states;
people.renderView = data => ;
person.renderView = data => ;
return stateNavigator;
}