What is alternative of .PageMode.IsExperienceEditor property of Sitecore.Context in JSS-react to verify the ExperienceEditor context ?

In addition to the built-in helper method, the pageState (normal, preview, editing) and pageEditing (boolean) properties are also available in the layout service context, which there are samples of in each JSS sample app:

screenshot

That would be isExperienceEditorActive defined in @sitecore-jss/sitecore-jss.

Usage:

import { isExperienceEditorActive } from "@sitecore-jss/sitecore-jss";

if (isExperienceEditorActive()) {
  // Do something special in the Experience Editor
}

This file also contains other very useful functions.

Credits to Corey Smith and Kam Figy who told me about this.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.