我有一个创建选择器,它返回需要三个参数,我无法使用useSelector((正确传递它们。
const participantCourseApplications = useSelector((state) =>
selectParticipantCourseApplicationIds(state, user.id, courseId)
);
这是我从应用程序中创建的选择器PiSlice
export const selectParticipantCourseApplicationIds = createSelector(
[
selectAllApplications,
(state, participantId) => participantId,
(state, courseId) => courseId,
],
(applications, participantId, courseId) =>
applications
.filter(
(filteredApplication) =>
filteredApplication.participants.includes(participantId) &&
filteredApplication.courseId === courseId
)
.map((mappedApplication) => mappedApplication.id)
);
您的第二个和第三个选择器都使用第二个参数,而不是第三个参数。
[
selectAllApplications,
(state, participantId) => participantId,
(state, _, courseId) => courseId,
],
这将使用第三个作为courseId。