9

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

2 Answers 2

10

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.

1
  • The isExperienceEditorActive() function was removed somewhere in 2021. It was replaced by the isEditorActive() function. Commented Mar 25 at 15:57
11

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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