casl react redux code example
Example: casl react redux
import { AbilityBuilder } from 'casl'
function subjectName(item) {
if (!item || typeof item === 'string') {
return item
}
return item.__type
}
export default AbilityBuilder.define({ subjectName }, can => {
can(['read', 'create'], 'Todo')
can(['update', 'delete'], 'Todo', { assignee: 'me' })
});