How to use routes - 10 common examples

To help you get started, we’ve selected a few routes 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 reactioncommerce / example-storefront / src / pages / auth.js View on Github external
setToken() {
    // parse the url params from Keycloak
    const params = this.getUrlParams();

    if (typeof window !== "undefined" && params.access_token) {
      const { keycloakAuthStore } = this.props;

      keycloakAuthStore.setToken(params.access_token);

      const previousRoute = localStorage.getItem("kc-redirected-from");
      localStorage.removeItem("kc-redirected-from");
      Router.pushRoute(previousRoute || "/");
    }
  }
github reactioncommerce / example-storefront / src / components / SearchInput / SearchInput.js View on Github external
function handleSearch({ keyCode, target }) {
  // Send user to grid page when the enter key is pressed.
  // The current search string will be appended to the URL as a query param.
  if (keyCode === 13) {
    const { value } = target;
    const route = value === "" ? "/" : `/?search=${value}`;
    Router.pushRoute(route);
  }
}
github resource-watch / resource-watch / pages / app / ExploreDetailPrivate.js View on Github external
handleTagSelected(tag, labels = ['TOPIC']) { // eslint-disable-line class-methods-use-this
    const tagSt = `["${tag}"]`;
    let treeSt = 'topics';
    if (labels.includes('TOPIC')) {
      treeSt = 'topics';
    } else if (labels.includes('GEOGRAPHY')) {
      treeSt = 'geographies';
    } else if (labels.includes('DATA_TYPE')) {
      treeSt = 'dataType';
    }

    Router.pushRoute('explore', { [treeSt]: tagSt });
  }
github Automattic / delphin / app / components / ui / language-picker / index.js View on Github external
handleChange( event ) {
		const locale = event.target.value;
		const currentLanguage = this.getCurrentLanguage();
		const nextLanguage = find( config( 'languages' ), { langSlug: locale } );

		if ( currentLanguage.isRtl !== nextLanguage.isRtl ) {
			// RTL and LTR languages use a different build, so we need to
			// reload the page if the language direction changes
			window.location.href = getPath( 'home', {}, { locale } );
		} else {
			this.props.switchLocale( locale );
			this.props.hideSelect();
		}
	}
github Automattic / delphin / app / components / containers / search-form.js View on Github external
redirectToSearch( query, numberOfResultsToDisplay ) {
			if ( query !== ownProps.location.query.q || config( 'initial_number_of_search_results' ) === numberOfResultsToDisplay ) {
				// reset the result count when the query changes and hide it from the url if it is the default
				numberOfResultsToDisplay = undefined;
			}

			dispatch( push( {
				pathname: getPath( 'search' ),
				query: { q: query, r: numberOfResultsToDisplay }
			} ) );
		}
	} )
github reactioncommerce / example-storefront / src / components / NavigationMobile / NavigationItemMobile.js View on Github external
onClick = () => {
    const { navItem } = this.props;

    if (this.hasSubNavItems) {
      this.setState({ isSubNavOpen: !this.state.isSubNavOpen });
    } else {
      const path = this.linkPath;
      Router.pushRoute(path, { slug: navItem.slug });
    }
  };
github Automattic / delphin / app / components / ui / update-contact-information / index.js View on Github external
<p>
					{ i18n.translate( 'You may be asked to approve these changes for each domain separately. ' +
										"We'll email you with instructions." ) }
					</p>
				}

				<p>
					{ i18n.translate(
						'By clicking "Update contact information", you agree to the ' +
						'{{draLink}}Domain Registration Agreement{{/draLink}} and confirm that if you are transferring ownership of the domain, ' +
						'the new owner has agreed in writing to be bound by the same agreement. {{faqLink}}What does this mean?{{/faqLink}}',
						{
							components: {
								draLink: <a rel="noopener noreferrer" href="https://wordpress.com/automattic-domain-name-registration-agreement/">,
								faqLink: </a><a rel="noopener noreferrer" href="{">
							}
						}
					) }
				</a></p><a rel="noopener noreferrer" href="{">
			
		);
	}
</a>
github Automattic / delphin / app / components / containers / home.js View on Github external
selectDomain( domainProduct, isUserLoggedIn ) {
			dispatch( selectDomain( domainProduct ) );

			if ( isUserLoggedIn ) {
				dispatch( push( getPath( 'contactInformation' ) ) );
			} else {
				dispatch( push( getPath( 'signupUser' ) ) );
			}
		}
	} ),
github Automattic / delphin / app / components / containers / home.js View on Github external
redirectToSearch( query ) {
			dispatch( push( {
				pathname: getPath( 'search' ),
				query: { q: query }
			} ) );
		},
github openpitrix / dashboard / src / pages / Dashboard / Overview / index.jsx View on Github external
handleClickTotalCard = (label, type) => {
    label = `${label}`.toLocaleLowerCase();
    const guessRoute = routes.portal[type][label] || routes.portal[label];
    this.props.history.push(toRoute(guessRoute));
  };

routes

Minimalist route matching for javascript

Unknown
Latest version published 9 years ago

Package Health Score

51 / 100
Full package analysis