Lenra Docs
Register on Lenra
  • Home
  • Getting started
    Open/Close
  • Guides
    Open/Close
  • Features
    Open/Close
  • References
    Open/Close
  • Contribute

    View

    This component calls a view defined in the application. This can be used to create reusable views across the application and call them from anywhere.

    The view must be defined and references in the index.js root file of the application.

    Examples

    Simple view

    Create a file that will contain the view.

    module.exports = (users, _props) => {
      return {
        "type": "text",
        "value": "This is a view",
      };
    }
    

    Then instantiate the view in the root view of the application.

    module.exports = (users, _props) => {
      return {
        "type": "flex",
        "children": [
            {
                "type": "text",
                "value": "This the root view",
            },
            // Will call myView and show the "This is a view" text
            {
                "type": "view",
                "name": "myView",
            }
        ]
      };
    }
    

    Properties

    AttributeDescriptionType
    _typeThe identifier of the component
    • view
    nameThe name of the viewstring
    contextThe context projection. This field represents the projection of the context, allowing selective retrieval of specific elements. It is a map that specifies the desired elements to be included in the projection.object
    findFind query.Find
    propsParameters passed to the listenerobject