search

Home  >  Q&A  >  body text

Deprecated: Selectors with props are no longer supported

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粉786800174P粉786800174355 days ago475

reply all(1)I'll reply

  • P粉465287592

    P粉4652875922024-02-22 14:34:19

    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,
    });

    reply
    0
  • Cancelreply