React Bricks

AdminContext


The AdminContext provides the context needed by the admin editing interface.

It has the following interface:

interface IAdminContext {
    isAdmin: boolean
    user: User | null
    setUser: (user: User) => void
    currentPage: string
    setCurrentPage: (page: string) => void
    previewMode: boolean
    setPreviewMode: (previewMode: boolean) => void
    sidebarCollapsed: boolean
    setSidebarCollapsed: (sidebarCollapsed: boolean) => void
    getStyles: () => NodeListOf<HTMLStyleElement> | []
    getStylesheets: () => NodeListOf<HTMLLinkElement> | []
  }

The Admin component wraps all the children with the AdminContext Provider.

If you need to access this admin status variables in your components, you may use React useContext to access them.

In particular, you may use isAdmin in your bricks (block components) to do conditionally render based on the fact that the brick is in edit mode or view mode.