How to use the navigation.HTML5HistoryManager function in navigation

To help you get started, we’ve selected a few navigation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redbadger / website-honestly / site / components / link / test-helper.js View on Github external
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;
}
github redbadger / website-honestly / site / routes / index.js View on Github external
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;
};
github grahammendick / navigation / NavigationReact / sample / isomorphic-codesplitting / getStateNavigator.js View on Github external
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());
};
github grahammendick / navigation / NavigationReact / sample / isomorphic / getStateNavigator.js View on Github external
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;
}