Fetches the layout from a model, and updates the layout on model changes. Calls either the QIX API method getAppLayout or GetLayout.
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>
);
};
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.