Mastering Redux with React code example
Example 1: how to install react redux
yarn add redux react-redux --save
Example 2: 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' })
});