What is alternative of .PageMode.IsExperienceEditor
property of Sitecore.Context
in JSS-react to verify the ExperienceEditor context ?
2 Answers
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.
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: