@j2inn/app-react
Version:
React implementation of the j2inn-app framework
21 lines (20 loc) • 730 B
JavaScript
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
import { observer } from 'mobx-react-lite';
import { useAppRootStore } from '../hooks';
/**
* A high-order level component that performs app access level checks before
* rendering any children.
*
* ```
* <AppAccessChecker app='myAppId' access='read'>
* <div>
* This content will only render if the user has read access permissions
* for the `myAppId` application.
* </div>
* </AppAccessChecker>
* ```
*/
export const AppAccessChecker = observer(({ app, access, children }) => {
const rootStore = useAppRootStore();
return _jsx(_Fragment, { children: rootStore.hasAppAccess(app, access) && children });
});