You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

The SPA front-end helper libraries provide APIs through which you can stay informed about the status of the current renderer context of an SPA page. The status can be that your SPA page is running in:

  • A developer mode.
  • The page editor of the Pages app.
  • The preview mode of the page editor.

Being aware of the current renderer context can be useful if you need to hit different URLs for content, do rendering or other things conditionally. The status information is retrievable in both frameworks integrating SPA development in Magnolia – Angular and ReactJS.

In Angular

In the Angular framework, the status of an SPA page being in the developer mode can be checked by calling the isDevMode() function, which is part of the @angular/core library.

To find out in Angular whether your SPA page is running in the page editor or in its page preview mode, inject the RendererContextService from the @magnolia/angular-editor. You can then call the following functions to get the status:

  • inEditor()
  • inEditorPreview()

In ReactJS

To retrieve the status in ReactJS, make sure that you import {RendererContext} from the @magnolia/react-editor, and that the class of YourComponent extends the React.Component

After assigning static contextType = RendererContext you can call the following functions to get the status:

  • this.context.isDevMode
  • this.context.inEditor
  • this.context.inEditorPreview
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels