How to use @sitecore-jss/sitecore-jss-react - 10 common examples

To help you get started, we’ve selected a few @sitecore-jss/sitecore-jss-react 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 Sitecore / jss / samples / react / src / components / Styleguide-FieldUsage-Number / index.js View on Github external
const StyleguideFieldUsageText = (props) => {
  const fieldValue = getFieldValue(props.fields, 'sample');

  return (
    
      {/* Basic emission of a number field for editing can be done with the 
  );
};
github Sitecore / Sitecore.HabitatHome.Omni / fitness / app / src / RouteHandler.js View on Github external
componentDidUpdate(previousProps) {
    const existingRoute = previousProps.route.match.url;
    const newRoute = this.props.route.match.url;

    // don't change state (refetch route data) if the route has not changed
    if (existingRoute === newRoute) {
      return;
    }

    // if in experience editor - force reload instead of route data update
    // avoids confusing Sitecore's editing JS
    if (isExperienceEditorActive()) {
      window.location.assign(newRoute);
      return;
    }

    this.updateLanguage();
    this.updateRouteData();
  }
github Sitecore / jss / samples / basic-sample-react-graphql / src / boot / RouteHandler.js View on Github external
componentWillReceiveProps(newProps) {
    const existingRoute = this.props.route.match.url;
    const newRoute = newProps.route.match.url;

    if (existingRoute !== newRoute) {
      // if in experience editor - force reload
      if (isExperienceEditorActive()) {
        window.location.assign(newRoute);
        return;
      }

      // get the route data for the new route
      SitecoreContentService.getRouteData(newRoute).then((routeData) => {
        if (routeData !== null) {
          // set the sitecore context data and push the new route
          SitecoreContextFactory.setSitecoreContext({
            route: routeData.sitecore.route,
            itemId: routeData.sitecore.route.itemId,
            ...routeData.sitecore.context,
          });
          this.setState({ state: routeData, notFound: false });
        } else {
          this.setState({ notFound: true });
github altola / sitecore-jss-react-starter / src / src / RouteHandler.js View on Github external
componentDidUpdate(previousProps) {
    const existingRoute = previousProps.route.match.url;
    const newRoute = this.props.route.match.url;

    // don't change state (refetch route data) if the route has not changed
    if (existingRoute === newRoute) {
      return;
    }

    // if in experience editor - force reload instead of route data update
    // avoids confusing Sitecore's editing JS
    if (isExperienceEditorActive()) {
      window.location.assign(newRoute);
      return;
    }

    this.updateLanguage();
    this.updateRouteData();
  }
github altola / sitecore-jss-react-starter / src / src / RouteHandler.js View on Github external
function getRouteData(route, language) {
  const fetchOptions = {
    layoutServiceConfig: { host: config.sitecoreApiHost },
    querystringParams: { sc_lang: language, sc_apikey: config.sitecoreApiKey },
    fetcher: dataFetcher,
  };

  return dataApi.fetchRouteData(route, fetchOptions).catch((error) => {
    if (error.response && error.response.status === 404 && error.response.data) {
      return error.response.data;
    }

    console.error('Route data fetch error', error, error.response);

    return null;
  });
}
github Sitecore / Sitecore.HabitatHome.Omni / fitness / app / src / RouteHandler.js View on Github external
}

  const systemQueryParams = {
    sc_lang: language,
    sc_apikey: config.sitecoreApiKey
  };
  const queryParams = Object.assign(currentUrlParams, systemQueryParams);

  const fetchOptions = {
    layoutServiceConfig: { host: config.sitecoreApiHost },
    querystringParams: queryParams,
    requestConfig: options,
    fetcher: dataFetcher
  };

  return dataApi.fetchRouteData(route, fetchOptions).catch((error) => {
    if (error.response && error.response.status === 404 && error.response.data) {
      return error.response.data;
    }

    console.error('Route data fetch error', error, error.response);

    return null;
  });
}
github Sitecore / jss / samples / react / src / components / Styleguide-FieldUsage-Checkbox / index.js View on Github external
*/}
      {props.fields &&
        props.fields.checkbox &&
        props.fields.checkbox.value && (
          <li>
            <code>checkbox</code> is true
          </li>
        )}
      {!props.fields ||
        !props.fields.checkbox ||
        (!props.fields.checkbox.value &amp;&amp; (
          <li>
            <code>checkbox</code> is false
          </li>
        ))}
      {getFieldValue(props.fields, 'checkbox2', false) &amp;&amp; (
        <li>
          <code>checkbox2</code> is true
        </li>
      )}
      {!getFieldValue(props.fields, 'checkbox2', false) &amp;&amp; (
        <li>
          <code>checkbox2</code> is false
        </li>
      )}
    
  
);
github Sitecore / jss / samples / react / src / components / Styleguide-FieldUsage-Checkbox / index.js View on Github external
<code>checkbox</code> is true
          
        )}
      {!props.fields ||
        !props.fields.checkbox ||
        (!props.fields.checkbox.value &amp;&amp; (
          <li>
            <code>checkbox</code> is false
          </li>
        ))}
      {getFieldValue(props.fields, 'checkbox2', false) &amp;&amp; (
        <li>
          <code>checkbox2</code> is true
        </li>
      )}
      {!getFieldValue(props.fields, 'checkbox2', false) &amp;&amp; (
        <li>
          <code>checkbox2</code> is false
        </li>
      )}
    
  
);
github Sitecore / jss / samples / basic-sample-react / src / app / data.js View on Github external
export const getRouteData = (route) => {
  switch (route) {
    case '/': {
      return convertRouteToLayoutServiceFormat(routes.home);
    }
  }
};

@sitecore-jss/sitecore-jss-react

This module is provided as a part of Sitecore JavaScript Rendering SDK (JSS). It contains React components and integration for JSS.

Apache-2.0
Latest version published 7 days ago

Package Health Score

66 / 100
Full package analysis

Similar packages