Deprecated: Selectors with props are no longer supported
P粉786800174
P粉786800174 2024-02-21 20:05:20
0
1
374

On the second line, I get this error: Selectors with props are deprecated.

const getUserProfileState = createFeatureSelector<UserProfileState>(authorizationFeatureKey);

const hasPermission = createSelector(
    getUserProfileState,
    (state: UserProfileState, permission: GQLPermission): boolean => {
        const result =
            state.permissions &&
            state.permissions.some((p) => p && p.resource === permission.resource && p.action === permission.action);
        return !!result;
    }
);

const hasCreateCasePermission = createSelector(getUserProfileState, (state: UserProfileState): boolean =>
    hasPermission.projector(state, {
        resource: PermissionResource.case,
        action: PermissionAction.create,
    })
);

I'm trying to refactor the "hasPermission" function like this:

const hasPermission = (permission: GQLPermission) => createSelector(
    getUserProfileState,
    (state: UserProfileState): boolean => {
        const result =
            state.permissions &&
            state.permissions.some((p) => p && p.resource === permission.resource && p.action === permission.action);
        return !!result;
    }
);

But I'm having difficulty on how to refactor based on this hasCreateCasePermission.

P粉786800174
P粉786800174

reply all(1)
P粉465287592

Side note: The use of .projector in the first example is a bit flavorful. You can do the following:

const hasCreateCasePermission = hasPermission({
        resource: PermissionResource.case,
        action: PermissionAction.create,
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!