Aplicar permisos a nuestro proyecto de react.
yarn add react-permission-lib
or
npm install react-permission-lib
import {PermissionContext} from 'react-permission-lib'
const [permissions, setPermissions] = useState([]);
setPermissions([
'user.show',
'user.create',
'user.update',
'user.delete',
'user.destroy'
]);
<PermissionContext.Provider value={permissions}>
// content
</PermissionContext.Provider>
import {Can} from 'react-permission-lib'
<Can permission={'user.show'}>
// content
</Can>
import {Middleware} from 'react-permission-lib'
<Route path="/" element={
<Middleware permission={'user.show'}>
<App/>
</Middleware>
}/>