Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.28 KB

useLayout.md

File metadata and controls

40 lines (30 loc) · 1.28 KB

useLayout

Fetches the layout from a model, and updates the layout on model changes. Calls either the QIX API method getAppLayout or GetLayout.

Usage

import { useLayout } from 'hamus.js';

const Demo = (model) => {

  const [layout, layoutError] = useLayout(model);
  
  let content = '';
  if (layoutError) {
    content = 'oops an error occurred';
  } else if (!layout) {
    content = 'Fetching layout...';
  } else {
    content = JSON.stringify(layout);
  }
  return (
    <div>
      {content}
    </div>
  );
};

Reference

const [layout, layoutError] = useLayout(model);

where model is an enigma.js version of either a QIX API Doc or a GenericObject. The model can be fetched with the useModel() hook.

Returns a layout object which is either an AppLayout or a GenericObjectLayout.